Learn you an interactive rebase and other fancy git stuff
This isn't going to be a technical article explaining how to actually do an
interactive rebase, there's a ton of good resources for that out there already (I recommend
checking out upcase's git course). The problem is it takes a bit of practice to
get the hang of these things and it's a pain to keep getting a practice repo in
a state where you can rebase it. If only you could practice this on whatever
branch you're working on at work, without getting yourself in a bad state. Well
that's what I wanted when I first started learning this stuff, so I added some
aliases to my
.gitconfig to facilitate this.
First of all I have
git spike this just checks out a new branch with the same
name as current branch postfixed with 'spike'.
# ~/.gitconfig [alias] spike = "!git checkout -b $(git rev-parse --abbrev-ref HEAD)-spike"
The part in the sub shell that grabs the current branch name is pretty useful
on its own so I have an alias (
git cb) just for that
# ~/.gitconfig [alias] cb = rev-parse --abbrev-ref HEAD spike = "!git checkout -b $(git cb)-spike"
Now we can quickly checkout a branch to experiment with and if we mess up we
can get back to our good branch, delete the spike and try again. You can easily
get back to your previous branch with
git checkout -.
Anyway, that's 200 words, stay tuned for part 2.