If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!
read the transcript!
git rebase -i lets you garden your commits
I use it like this:
1. make commits chaotically, git commit -am 'wip'
2. clean up with git rebase -i
before sending them off for code review
interactive rebase’s UI is a text file
when you run git rebase -i main
, it’ll open a text editor with something like this in it:
pick 399990 add some padding
pick fb59d8 french translation
pick 617b19 sort titles
pick 31b81f hashchange
deleting commits
You can delete a commit just by deleting that line in the text editor!
(same as previous panel but the “french translation” line is scribbled out)
combine commits with fixup
Here’s how to combine all 4 commits into 1 commit:
(f
stands for fixup
)
pick 399990 add some padding
f fb59d8 french translation
f 617b19 sort titles
f 31b81f hashchange
check that the tests pass with exec
You can run make test on every intermediate commit to make sure your tests pass like this:
git rebase -i --exec
"make test" main
(you can also use this to format every commit’s code!)
some other tips
reword
lets you edit a commit message- If something goes very wrong, I try to run
git rebase --abort
ASAP, because undoing rebases is annoying
Saturday Morning Comics!
Want another comic like this in your email every Saturday? Sign up here!