Adding `git squash` to my git workflow

This post was originally a TweetStorm. Read that tweetstorm.

This post is part of a group I’ve written about improving your version control skills.


I’m pretty sure that squashing commits is now going to be a part of my git workflow. I’ve had some serious level ups in my git workflow as I’ve continued working as a developer. This is definitely one of them.

The habit of regular small (even trivial) commits, was baked into me while going through Dev Bootcamp in Chicago with regular commit intervals on the half hour. I further cemented this by including a tool in my terminal prompt that told me the time since my last commit on my current branch, similar to what @Goles has written here for the Zsh terminal.

picture credit to Tuo Huang from this post

Eventually I learned of git commit patch and Gitx. I previously wrote about git committing interactively.

Some folks told me I was potentially making my commits too small! This is were git squash -ing becomes so useful.

With git squash in your VCS toolbelt it doesn’t matter that I wrote 1 commit every 30 minutes. Or turned an hour’s worth of work into 4 commits. Sometimes that story needs to be editing, which is where git squash comes in.

Now after my full git log of commits I can go back and edit.

git commit drunk, git squash sober

Git squash allows you to turn the three commits into one for that test you wrote. Or to turn the passing test and the correctly method into one single commit.

Allows you to totally remove an unused piece of git history, like the comment you added asking a question, which was then answered within the code review process on your great pull request.

Allows you to amend the first and second and third of a 30 commit git branch not just the last commit.

You can turn your Hobbit trilogy into the one movie it should’ve been, without that non-canon love triangle.

Now you might be asked to do this when contributing to Open Source Software or just opening a pull request against your team’s branch or repo.

Git squashing also pairs well with git cherry-picking. They are are similar, yet different skills. So check out git squashing and add it to your repertoire of git skills.

Additional Resources

  1. Github : @goles zsh_git_timer

  2. Git tip: show current branch and time elapsed since last commit in command line by Tuo Huang


If you enjoyed this post, please subscribe to my newsletter