最佳答案
我在Git中创建了一个新分支:
git branch my_branch
推它:
git push origin my_branch
现在假设有人在服务器上做了一些更改,我想从origin/my_branch
中提取。我做:
git pull
但我得到:
You asked me to pull without telling me which branch youwant to merge with, and 'branch.my_branch.merge' inyour configuration file does not tell me, either. Pleasespecify which branch you want to use on the command line andtry again (e.g. 'git pull <repository> <refspec>').See git-pull(1) for details.
If you often merge with the same branch, you may want touse something like the following in your configuration file:
[branch "my_branch"]remote = <nickname>merge = <remote-ref>
[remote "<nickname>"]url = <url>fetch = <refspec>
See git-config(1) for details.
我知道我可以让它工作:
git branch --set-upstream my_branch origin/my_branch
但是为什么我需要对我创建的每个分支执行此操作?如果我将my_branch
推入origin/my_branch
,那么我想将origin/my_branch
拉入my_branch
,这不是很明显吗?我如何使这成为默认行为?