Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove an unwanted merge commit and rebase instead with Git

Tags:

I have a feature branch off develop. I started using the practice of rebasing my feature branch with develop instead of merging as the benefits of a linear commit history was appropriate for my project which had a few upstream and downstream repositories.

I'm in the situation where someone merged develop into the feature branch and did some more commits then pushed to the remote. I would like to be able to get the point where I remove the merge commit and cherry pick the subsequent commits on the branch. This is with the knowledge that other people working on the branch will have to basically delete their local ones and pull down the revised one. I work in a small team and this is manageable.

Is the best method to do this an interactive rebase selecting all the commit bar the merge commit?

So git rebase -i commit-sha-before-merge

I know this will most likely result in a broken build as the commits that occurred after the merge relied on the code in the merge. I will resolve this with finally rebasing my feature branch with develop.