在先前的提交合并主控之后将分支合并到主控中然后将其还原
merging branch into master after a previous commit merged master then reverted it
为我要修复的问题提供更多背景信息。一些开发人员在同一个分支工作。在某些时候,有人试图将 master 合并到子分支中,但出现了错误(无法构建项目等。不是 100% 确定)但随后立即恢复了 master 合并提交。子分支现在 "complete" 并准备好进行拉取请求,现在它不会完全合并到主分支中。几个 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 的最佳方法是什么?
如果开发人员不介意 squasing/rebasing-or-merging 清理他的工作并在一次修订中完成所有工作,这个技巧可能会奏效(这个技巧 不会 关心以前的messed-up历史,只要合并工作正常):
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
然后玩得开心。
为我要修复的问题提供更多背景信息。一些开发人员在同一个分支工作。在某些时候,有人试图将 master 合并到子分支中,但出现了错误(无法构建项目等。不是 100% 确定)但随后立即恢复了 master 合并提交。子分支现在 "complete" 并准备好进行拉取请求,现在它不会完全合并到主分支中。几个 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 的最佳方法是什么?
如果开发人员不介意 squasing/rebasing-or-merging 清理他的工作并在一次修订中完成所有工作,这个技巧可能会奏效(这个技巧 不会 关心以前的messed-up历史,只要合并工作正常):
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
然后玩得开心。