Zaonce...
loading...

This Planet is a Tedious Place...

23/06/16 Did that interactive git rebase work?

When I do a non-trivial interactive git rebase, I almost always want to check that there are no unexpected differences between my final commit and the original pre-rebase commit. I usually remember half way through the rebase to add a branch to the original commit, and add it using gitk, as it's handily displaying the pre-rebase history.

I've finally realised that I could make this much simpler with a hook, so I've added a local git hook (.git/hooks/pre-rebase) which contains the following:

#!/bin/sh
git branch before-rebase-`date "+%H%M%S"`


This will add the branch, named something like before-rebase-121451, for you automatically.

It will need manually removing afterwards, once you're happy, but makes it much easier to see where you were if you forgot before you started.

Once you've completed the rebase, you can just select the original commit (indicated by the branch) and compare the differences with the new head commit. It also means you can go back to the pre-rebase commit easily if the result is not what you intended.

posted by Gruntfuggly # 12:25 Comments...


Somebody # 31/08/16 01:23

 

Add Comment