我在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 you
want to merge with, and 'branch.my_branch.merge' in
your configuration file does not tell me, either. Please
specify which branch you want to use on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details.
If you often merge with the same branch, you may want to
use 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
吗?如何使它成为默认行为?
--set-upstream
选项已弃用。您应该使用--track
或--set-upstream-to
代替。
--set-upstream
已弃用,那么git devs应该从git push
没有选项且没有设置上游运行时显示的帮助消息中删除它吗?
git branch --set-upstream
已过时。git push --set-upstream
不是。
branch.autosetupmerge
表示仅在从远程跟踪分支(例如<remote-name>/<branch-name>
)创建分支时自动设置新分支的上游配置(请参阅git-config(1))。您可能是从现有的本地分支创建分支。如果您是直接从远程分支的顶端有效分支(尽管位于本地分支上),则可以使用它git branch my_branch <remote-name>/<branch-name>
来自动设置上游配置。