Suppose I have a mainline branch and a feature branch. I have merged the mainline branch into the feature branch many times, but I have only had a few, very minor merge conflicts. I want to clean up the history so that there is only a single merge at the end. What is the best method for doing this?
Have you looked into git rebase
?
git co -b temp_feature feature
git rebase master
This should ignore the merges, but you will have to re-resolve the conflicts. It also creates temp_feature branch for easier go back but same could be achieved with reflog.
(Wrong answer below: this will create single commit, not a single merge :-/)
I think the simplest is to do following:
git co master
git merge --squash feature
This will create single commit from whole feature branch. If you do not want to keep the feature branch do:
git branch -D feature
Sounds like you want to cherrypick the non-merge commits for the feature branch into clean-feature branch, then finally merge clean-feature branch with the latest master (whatever that is). You can use rebase to speedup part of that cherrypicking, which unfortunately I don't know of a good way to do in a jiffy, since this is not something I do very often. It would help if you have a gui that allows you to select multiple commits to be cherrypicked at once.
Edit: This would be a more concrete solution: How to cherry pick a range of commits and merge into another branch
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With