How to review git merge branches
This is something that we hit often at work due to our git branching strategy. A new release lands in master
and we need to update other in-progress releases with the new code. It goes something like
# after release-1 is merged into master
git fetch
git checkout release-2
git branch -b merge-master-into-release-2
git merge origin/master
# then create a pull request
And the pull request ends up looking something like:
which is pretty much un-reviewable, I've always just accepted that these PRs need a quick look over – but because all the code has already been reviewed and released they don't need a detailed review. The problem is that sometimes there can be issues hidden in merge conflicts. I finally got around to doing a bit of googling and came across this great article that explains that you can just use git show
to display only what was changed in the merge conflicts. You can take this a step further by using tig show
from the excellent tool tig to get a nicer output.
This certainly makes it a ton easier to review what conflicts were resolved in a merge PR.
git checkout merge-master-into-release-2
tig show