本地新建分支推送后再次拉取的错误
本地新建分支推送后再次拉取的错误
本地新建一个分支后,必须要做远程分支关联。如果没有关联,git会在下面的操作中提示你显式的添加关联。关联目的是如果在本地分支下操作: git pull, git push ,不需要指定在命令行指定远程的分支.
git在本地新建分支, push到remote服务器上之后,你只要没有显示指定, git pull 的时候,就会提示你。
git push --set-upstream origin dev
等价于
<font style="color:#4D4D4D;">git push -u origin my_branch</font>
origin 是默认的远程版本库名称
在你第一次提交你的分支的时候使用。它会像<font style="color:#4D4D4D;">git branch --set-upstream</font>一样在本地分支与远程分去建立联系。
我在 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
posted on 2025-10-13 17:41 chuchengzhi 阅读(9) 评论(0) 收藏 举报
浙公网安备 33010602011771号