How to squash all git commits into one?

Verhogen picture Verhogen · Nov 1, 2009 · Viewed 244.6k times · Source

How do you squash your entire repository down to the first commit?

I can rebase to the first commit, but that would leave me with 2 commits. Is there a way to reference the commit before the first one?

Answer

Jordan Lewis picture Jordan Lewis · Feb 13, 2012

As of git 1.6.2, you can use git rebase --root -i.

For each commit except the first, change pick to squash.