git - 悬空的 Twig ?

标签 git git-branch remote-branch

这可能是一个已经被问到的问题,但我只是不知道调用该问题的正确名称是什么 - 所以请指导我或回答(是的,我见过 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 pushgit 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/

相关文章:

git - 在 git 中的远程存储库上创建私有(private)分支

git - 是否可以在 gitk 中配置差异?

visual-studio-2010 - 将visual studio 2010连接到assembla SVN

git - 更改 Git 远程 HEAD 以指向 master 以外的内容

git - 使用 Git 对所有远程分支进行头提交

git - 如何列出 Git 1.7+ 中的所有远程分支?

git - 在 merge 过程中如何优先选择一个分支中的文件?

git - 在不破坏文件历史记录的情况下 merge 两个 Git 存储库

git - 使用成功的 Git 分支模型支持多个版本

git - 以特殊格式收集存储库中所有分支的列表 [Git]