我通常使用以下命令切换分支
git fetch && git checkout branch在此之后,我通常检查是否正在通过git info处理我想要的分支,这将突出显示我正在处理的本地分支(在分支名称旁边有一个星号*)。
今天我遵循了相同的模式,但是git仍然保留在主分支中,即使在运行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看起来很正常;我不确定第二个origin/HEAD -> origin/master。
这里面有奇怪的东西,但我还没弄明白。
发布于 2015-07-06 13:27:05
看来我有个发散的主人了。
奇怪的是,这个命令没有显示任何错误日志。
$ 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命令没有正确执行。
发布于 2015-07-06 13:29:13
请注意,git fetch将只提取.git/config文件中配置的引用--它可能没有得到您预期的结果。如果您没有设置远程跟踪分支,那么它将不知道如何从远程分支中提取内容。
此外,'git结帐母版‘将始终切换到您的分支名为master,而不是远程主机碰巧是什么。因此,您已经创建了一个名为“主人”的分支,上面的内容根本不会改变它。
https://stackoverflow.com/questions/31245941
复制相似问题