【发布时间】:2017-11-09 23:34:33
【问题描述】:
我刚刚完成了 2 个独立的开发分支的工作,这些分支最初是从主主分支分支出来的。这是我在从主分支分支以创建这 2 个开发分支时使用的流程:
Master
|--> DevelopBranch1
|
-->DevelopBranch2
所以最初我通过从Master 分支创建DevelopBranch1。然后我通过分支DevelopBranch1 创建了DevelopBranch2。我做出这个决定的原因是因为DevelopBranch2 取决于我在DevelopBranch1 中所做的新更改。
我已完成对 DevelopBranch1 的更改。由于DevelopBranch2 最初不是从Master 分支出来的,所以我现在想做一些事情:
1) 将DevelopBranch1 合并为Master
2) 将DevelopBranch2 重新映射到Master
3) 将DevelopBranch2 合并为Master
4) 存档DevelopBranch1
我成功地将DevelopBranch1 合并到Master 中,方法是使用SourceTree 签出Master 并将其与DevelopBranch1 的最新提交合并。
当我进入第 2 步时,这就是我遇到问题的地方。我使用了以下 git 命令来重新设置父级:
git checkout master
git rebase --onto DevelopBranch2
在 rebase 命令之后,我注意到在 SourceTree 中来自Master 的最新提交被移动到了DevelopBranch2 中的最新提交。
此时,我尝试将Master 合并到DevelopBranch2。使用此 Merge 并运行 git status 后,我收到以下消息
On branch master
Your branch and 'origin/master' have diverged,
and have 5 and 7 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
然后我运行git pull 并收到此消息:
git pull
error: Pulling is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
这是我目前卡住的地方。
任何帮助将不胜感激!
【问题讨论】:
-
除非您有一个非常古老的 Git(例如 1.7.x),否则
git status输出和随后对未合并文件的抱怨似乎无法正确混合。如果您确实拥有如此古老的 Git,那么这一切都说得通。 -
@torek 我能够通过使用
git reset --hard master恢复此更改,感谢这篇文章:stackoverflow.com/questions/2452226/… 我认为我遇到的问题是正确使用git rebase来重新设置。跨度> -
一般来说,你要非常小心
git reset --hard。我应该问的是:你运行的是什么版本的 Git? -
@torek git --version git 版本 2.14.3.windows.1
-
好的,那么我很困惑,因为
git status应该显示正在阻止git pull的合并进行中。这可能是某些特定于 Windows 的东西。
标签: git merge version-control