to provide some more context around what I'm trying to fix. a few developers were working in the same branch. at some point, one tried to merge master into the child branch, something went wrong (couldn't build project, etc. not 100% sure) but then immediately reverted the master merge commit. the child branch is now "complete" and ready for a pull request and now it won't merge cleanly into master. several of the git
errors state something similar to the following?
CONFLICT (modify/delete): someFileName.cs deleted in HEAD and modified in master
we've tried the following
(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
all result in the same type of error mentioned above when attempting to merge back into master.
what is the best way to fix this branch to get it to merge cleanly back into master?
If the developr doesn't mind squasing/rebasing-or-merging to clean up his work and get it all done in a single revision, this trick might work (this trick doesn't care previous messed-up history as long as the merge works fine):
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
And then have fun with it.