Zach Olivare - 2022 May 11
An update to an old post that only worked on Windows
Several years ago I wrote a blog post with the goal of creating an alias for
git rebase -i head~N, which I have always found quite irksome to type. The post overall is a bit preachy, but I stand by the problem it was trying to solve and the solution it provided.
The solution I gave in that post used a batch script, which will only work in Windows. In the intervening years, my development machine of choice has become a Mac, and my shell of choice ZSH.
Since making the switch to Mac, I have honestly missed my
i N alias for
git rebase -i head~N, and I hadn't put in the time to figure out a unix way to handle it...until today!
The solution is frustrating simple. So simple that I deeply regret it taking me this long to figure it out.
Open up your
~/.zshrc and drop in the following function:
Now reload your terminal, navigate to a git repository, and run
i 3. Done ✅
I've found that almost every time I want to do a quick little interactive rebase it's so that I can add more changes to a previous commit (that's not the most recent commit in which case you would just use
To make that process faster, the version of the
i function that I use day to day actually looks like this: