Monday, September 26, 2016

Convenient git rebase while resolving merge conflicts


If you are in distributed development team, you've most probably run into merge conflict situation.
For example: your local changes conflict with recent repository updates.

Well, you can merge your local branch, resolve conflicts, and then push your changes upstream.


git checkout master
git merge myfix
git push

In gerrit workflow merge is effectively replaced with rebase operation:

git checkout myfix
git rebase origin/master
# resolve conflicts here
git rebase --continue

At this point you can be surprised by a need to do one more conflict resolve.

Omitting the reason of it, this is how I avoid this redundancy:

git checkout myfix
git rebase --onto origin/master HEAD^ HEAD
# resolve conflicts here
git rebase --continue

and this is it.

git review

No comments:

Post a Comment