2015-07-06 32 views
3

我通常使用此命令git的结帐分支,但仍然在主

git fetch && git checkout branch 

之后转分支,我通常会检查我的工作我通过git info旨在分支,这将突出地方分公司我正在工作(在分支名称旁边带有星号*)。

我今天遵循同样的模式,但不知何故混帐保持分支,我跑git fetch && git checkout branch即使经过。从命令行有没有错误日志。但在此之后,git info显示类似的东西(本地分支仍然,而不是分支线程,我想切换到)。

## Remote Branches: 

    origin/HEAD -> origin/master 
    origin/master 
    origin/threads 

    ## Local Branches: 

    * master 

比较正常的情况下(当如预期git checkout branch作品) - 奇怪的事情似乎是有两个origin/master,第一origin/HEAD -> origin/master似乎正常;我不确定第二个。

在这里有一些奇怪的东西,但我还没有想出。

+0

难道'git fetch'失败了吗? – kostya

+0

我发布'git fetch',但也没有错误日志。 – artm

+0

你似乎没有'origin/threads'的本地跟踪分支 - 你有没有在这个特定的分支中使用它,在这个特定的回购实例中? – Useless

回答

1

它看起来像我有一个分歧的主人。

奇怪的是,这个命令没有显示任何错误日志。

$ git fetch && git checkout threads # threads is the name of the branch 

但是,

$ git fetch && git checkout master 
    Switched to branch 'master' 
    Your branch and 'origin/master' have diverged, 
    and have 7 and 3 different commits each, respectively. 
    (use "git pull" to merge the remote branch into yours) 

,并

$ git pull origin master 
    From <git_repo>  # <git_repo> is the URL of the repo 
    * branch   master  -> FETCH_HEAD 
    Auto-merging <file> # <file> is the filename in question 
    CONFLICT (add/add): Merge conflict in <file> 
    Automatic merge failed; fix conflicts and then commit the result. 

后,我手动解决上冲突,现在git fetch && git checkout threads工作正常,我可以切换到分支线程

至于为什么我第一次得到分歧主,我不确定 - 可能是因为我的一些git rebase命令没有做好。

0

请注意,git fetch只会根据您的.git/config文件中的配置拉动参考 - 它可能没有达到您的预期。如果你还没有设置远程追踪分支,那么它不知道从远程分支拉下来的东西。

此外,'git checkout master'将始终切换到您的分支,称为主分支,而不是远程主分支。所以你创建了一个名为'master'的分支上面的分支根本不会改变它。