提供有关我要修复的内容的更多上下文。一些开发人员正在同一分支中工作。在某个时候,有人试图将master合并到子分支中,出了点问题(无法构建项目等,不能100%确定),但随后立即恢复了master merge提交。子分支现在“完成”并准备进行拉取请求,现在它不会干净地合并到主分支中。几个git
错误指出与以下内容类似的内容?
CONFLICT (modify/delete): someFileName.cs deleted in HEAD and modified in master
我们尝试了以下
(1)
- checked out/pulled latest master
- created a new branch
- cherry picked all relevant commits going forward
(2)
- performed a git reset to earliest commit
- cherry picked all relevant commits going forward
在尝试重新合并回master时,都导致上述类型的错误。
修复此分支以使其完全合并回master的最佳方法是什么?
答案 0 :(得分:1)
如果开发人员不介意压缩或重新合并以完成其工作并在单个修订版中完成所有工作,则此技巧可能会起作用(此技巧不在乎只要合并正常,就可以保留以前的混乱历史记录:
git checkout --detach feature-branch
git merge master "merge latest changes from master"
git reset --soft master # here is where the trick happens. after this command, all the changes that are related to the feature should be on index
git commit -m "Feature X: here is what the feature is about or what the change is about" # this revision has the whole thing on a single unique revision after master. No relation to the previous branch
# if you like the results, move the feature pointer
git branch -f feature-branch
然后玩它。