git切换远程库 创建分支并提交到远程

  • Post author:
  • Post category:其他



Git

切换远程库


git remote set-url origin –push


git远程仓库地址


Git

创建分支提交到远程时

git push origin 2.7.5.2:2.7.5.2

git branch –set-upstream-to=origin/2.7.5.1

这个命令是为了

git push



git pull

的时候用的



操作步骤如下:


git创建分支并切换到当前新创建的分支上

git checkout -b dev

开发完成后

git push origin dev

此时就将本地分支推送到远程相应的分支上了

此时,团队里另一个成员要更新远程dev分支上的代码

git pull

若出现如下错误

$ git pull
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 3 (delta 0)
Unpacking objects: 100% (3/3), done.
From github.com:michaelliao/learngit
   fc38031..291bea8  dev        -> origin/dev
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 dev origin/<branch>

 

git pull失败了,原因是没有指定本地dev分支与远程dev分支的链接。

根据提示设置

git branch --set-upstream dev origin/dev

此时又出现提示

The


--set-upstream flag is deprecated and  will be removed.Consider using --track or --set-upstream-to




Branch dev set up to track remote branch dev from origin.



于是重新设置

git branch --set-upstream-to origin/dev

然后就直接pull了

git pull

该同事修改完成后,又要将本地分支推送到远程dev分支

但他习惯性的用了

git push

于是出现了警告

warning:push.default is unset;its implicit  value has changed in Git 2.0 from ‘matching’ to ‘simple’ .

根据提示

我们设置

git config –global push.default simple

之后就可以直接用

git push

而不用再写

git push origin dev了



版权声明:本文为allanGold原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。