I don't know about you, but I suffer from

OCD - Over Committing Disorder


  1. You care about git history.
    • If you dont you might as well just close the laptop now.
  2. You know how to branch and are working on a feature branch. You dont have to be but it makes what I am about to show you easier
  3. You know how to rebase

I commit like its going out of style. The second I have made the source better (and the commit is stable)..

git status
git add app.js
git add index.html
git commit -m "Hello world displayed"

5 minutes pass

git status
git add app.js
git commit -m "Added period to hello world"

6 commits/1 minute later (It's time to merge into master)

git checkout master
git fetch
git rebase #one new commit


Meh I can just rebase, resolve some conflicts and we are ready to push to master.

git checkout helloWorld
git rebase master
>> resolve conflicts


This is a pretty respectable linear history... I can now just go back to master and merge helloWorld. We are one fast forward away from a clean push.


Most would just push. But I challenge you to make it cleaner. Lets restart this process and try it a different way.

Remember this state:


It's time to get these things into the trunk, but someone already committed something. We need to rebase those changes into our branch, so we can get a clean fast-foward. This time lets use an interactive rebase.

git rebase -i master


Woah! Don't be scared its just vim. I would explain what you can do here but git is smart enough to explain it to you. Right now we have a couple options we have complete control here to re-write history. I only care about squashing these into one commit, and fixing the log message.


Now if you are lucky you will not merge conflict. If you merge conflict, resolve them as normal. At the very end you will get an option to edit your rebase message.

But once we are done:


Ah, OCD can rest peacefully tonight.

Last tip. Some people might wonder what my alias git tr is all about:

git log --pretty=oneline --graph --decorate --all