Intro to Interactive Rebasing in Git

Lucas PenzeyMoog
3 min readApr 10, 2019

This will be old news to some, but I’ve always been told to write the blog post you wish you had when you started learning about a particular topic. So here’s what I just learned about interactive rebasing and customizing vim.

Interactive rebasing allows you to rewrite the history of your commits by editing the messages, squashing commits together, or even deleting commits entirely. Due to this functionality it’s best to proceed with caution. If it’s your first time with this process I recommend creating a new throwaway branch off of a relatively mature feature branch you’ve been working on to play around in.

It’s also worth noting that you should never make rewrites to a branch that’s already been shared with others. Interactive rebasing is best used when you want to clean up your personal branch before pushing.

Accessing the Right Commit

Running the command git rebase -i <hash or index here> is how you enter an interactive rebase session, and there are a few ways to tell git which commit you want to work on. You can either enter the hash of the commit (the yellow string below, found by entering git log --oneline) or you can use the index of the commit based on the current HEAD position.

--

--