当我使用本地分支mybranch
时,我想能够只使用git push
和git pull
来推送和拉取origin mybranch
的更改。目前,我必须费力地写出git push origin mybranch
和git pull origin mybranch
。如果我尝试只使用git pull
,例如,会出现以下错误:
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> mybranch
如果我输入git branch --set-upstream-to=origin/mybranch mybranch
,那么它就有效了。但这几乎与先前的命令一样繁琐。我能不能让git默认执行这个操作呢?我看到类似的问题被问过,答案往往表明较新版本的git会这样做,但我正在使用的是git版本2.1.3,这已经相当新了,所以不可能只是因为它。
git push -u origin mybranch
。从那时起,当您在mybranch
分支上时,只需运行git push
和git pull
即可。 - jub0bsgit config --global push.autoSetupRemote
可以提供帮助。 - VonC