- 添加账号和邮箱
- vi .gitconfig
- :w
- 一直回车就行,第一个回车,会有git的路径
- 切换到git的路径下面
- cat id_rsa.pub
- 放到web 的git ssh=新建中文
- git的启用必须在 你建立的文件下面
- 创建分支
- 会有bug-Not a valid object name: 'master':
- 现在这个目录下随便建立个文本
- git commit -m hosts.txt
- 按照提示必须都填写
- git config --global user.email "you@example.com"
- 会有bug-Not a valid object name: 'master':
git config --global user.name "Your Name"
- 还有就是从仓库区提交到服务器的时候,可能没有连接会报错
- 本地分支和远程分支断开连接
- cd 本地分支里
1、git branch
——*master 只显示master
然后查看是否从上游拉了
2、git remote –v
——若什么都没有,则和上游已断联系,拉不了代码也推不了代码
3、加关联
git remote add origin ssh://git@gitlab*********************************.git(地址)
-------------到这就可重新提交了------------------
若还不行:然后
4、git fetch origin
——会显示下拉的branch情况
格式为From ssh://gitlab.********************************
* [new branch] XXXXX ->origin/XXXXX
再次检查远程仓库,显示对应的clone地址
git remote –v
——origin git://github.com/schacon/ticgit.git (fetch)
origin git://github.com/schacon/ticgit.git (push)
然后再查分支
git branch –a
——* mater
remotes/origin/XXXXXX **********
具体的切换分支可参考https://blog.youkuaiyun.com/tanningzhong/article/details/79724488
git 重命名仓库、修改远程仓库地址、修改仓库配置可参考: https://blog.youkuaiyun.com/u011884440/article/details/71246572
-
在提交:master报错信息如下
To https://github.com/CashFu/selenium3Fu.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/CashFu/selenium3Fu.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
解决方法:
- 看到提示里面,感觉是本地的代码不是最新的。
所以觉得应该是类似于svn中的,先update一下,再去commit,估计就可以了。
所以先去pull试试---输入:$ git pull
结果直接pull好像是不对的:
$ git pull remote: Enumerating objects: 6, done. remote: Counting objects: 100% (6/6), done. remote: Compressing objects: 100% (3/3), done. remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (6/6), done. From https://github.com/CashFu/selenium3Fu * [new branch] master -> origin/master There is no tracking information for the current branch. Please specify which branch you want to merge with. See git-pull(1) for details. git pull <remote> <branch> If you wish to set tracking information for this branch you can do so with: git branch --set-upstream-to=origin/<branch> master
- 估计是指定对应的要pull的目标即可。
所以再去试试pull origin:
You asked to pull from the remote 'origin', but did not specify a branch. Because this is not the default configured remote for your current branch, you must specify a branch on the command line.
也还是不对。
- 再试试:git pull --rebase origin master
From https://github.com/CashFu/selenium3Fu * branch master -> FETCH_HEAD warning: unable to rmdir 'selenium3Fu': Directory not empty First, rewinding head to replay your work on top of it... Applying: hosts.txt Applying: lfittest_login—_lfj
可以看到,此时已经把github上最新的文件下载下来了
- 接着再去:
git push origin master
---------------ok了------------