您的位置:首页 > 其它

git pull push没有指定branch报错的解决方法

2017-06-21 10:11 801 查看
  git push --set-upstream origin master

git 执行git push 和git pull的操作时候,经常看到下面的提示:<br>
<br>
You asked me to pull without telling me which branch you<br>
want to merge with, and 'branch.dev.merge' in<br>
your configuration file does not tell me, either. Please<br>
specify which branch you want to use on the command line and<br>
try again (e.g. 'git pull <repository> <refspec>').<br>
See git-pull(1) for details.<br>
<br>
If you often merge with the same branch, you may want to<br>
use something like the following in your configuration file:<br>
<br>
[branch "dev"]<br>
remote = <nickname><br>
merge = <remote-ref><br>
<br>
[remote "<nickname>"]<br>
url = <url><br>
fetch = <refspec><br>
<br>
See git-config(1) for details.<br>
<br>
 <br>
<br>
在高版本的 git下面,也许会看见这样的提示:<br>
<br>
There is no tracking information for the current branch.<br>
<br>
Please specify which branch you want to merge with.<br>
<br>
See git-pull(1) for details<br>
<br>
git pull <remote> <branch><br>
<br>
If you wish to set tracking information for this branch you can do so with<br>
<br>
git branch --set-upstream master origin/<branch><br>
<br>
看到第二个提示,我们现在知道了一种解决方案。也就是指定当前工作目录工作分支,跟远程的仓库,分支之间的链接关系。<br>
<br>
比如我们设置master对应远程仓库的master分支<br>
<br>
git branch --set-upstream master origin/master<br>
<br>
这样在我们每次想push或者pull的时候,只需要 输入git push 或者git pull即可。<br>
<br>
在此之前,我们必须要指定想要push或者pull的远程分支。<br>
<br>
git push origin master<br>
<br>
git pull origin master.<br>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  branch git