当我使用本地分支mybranch
时,我希望能够使用只使用git push
和git pull
。事实上,我必须单调地写出git push origin mybranch
和git pull origin mybranch
。如果我尝试使用刚刚git pull
例如,我得到:使用git自动跟踪远程分支
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'就足够了。 – Jubobs 2015-04-02 20:55:32