这可能是一个已经被问到的问题,但我只是不知道调用该问题的正确名称是什么 - 所以请指导我或回答(是的,我见过 this 问题,但无法理解与答案相差很大)。
我正在尝试git pull
,但收到以下消息:
You asked me to pull without telling me which branch you
want to merge with, and 'branch.2012_05_09_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 "2012_05_09_my_branch"]
remote = <nickname>
merge = <remote-ref>
[remote "<nickname>"]
url = <url>
fetch = <refspec>
See git-config(1) for details.
看起来我的工作目录有点“挂起”,没有附加到任何分支,对吗?如果是这样 - 请建议如何将其连接回正确的分支(例如2012_05_09_my_branch
)。也许我的想法是错误的(作为一个完全的 GIT 新手),在这种情况下,请解释发生了什么以及我能做些什么。
提炼问题:我需要做什么才能成功运行 git push
和 git pull
而没有收到上述消息?
更新:当我运行git分支
时,我得到:
* 2012_05_09_my_branch
master
这有点可能意味着我位于本地2012_05_09_my_branch
分支上,该分支未连接到任何远程分支?
更新 N2: Why do I need to do `--set-upstream` all the time? - 作为补充 Material 非常值得阅读(现在才找到)。
最佳答案
这不是您的工作目录未附加到分支,而是您没有在本地分支的远程上设置什么是对等分支。您可以通过以下方式将它们“连接”在一起:
git branch --set-upstream 2012_05_09_my_branch remotes/<your remote>/2012_05_09_my_branch
其中<您的远程>是.git/config中定义的服务器服务器,通常(使用一台服务器时)是origin
编辑:更安全的方法是使用 remotes/<remote>/<branch>
而不是<remote>/<branch>
关于git - 悬空的 Twig ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10871429/