Git Squashing, what's going on here?
So, being a beginner to git and its associated commands and check ins, I needed a way of “squashing” the 15 or so check ins into one so others can see one checkin versus my save-a-holic-ness. I save a lot, whether it’s video games or code, and that includes commits to my local history. Squashing is combining commits into fewer to make the history much more readable. How does one squash their commits? With this magic command.
git rebase -i HEAD~3
This is what it does. The rebase command basically rewrites the local history (make sure you’ve not pushed to a remote repo though! You don’t want to mess up history for others) The -i makes it interactive, usually opening in your local editor or vi as a default for most OSes, and yes this includes Windows if you've installed git on Windows with the bash shell. The HEAD~3 part (no spaces between HEAD and ~3 though, and that is the tilde character before the 3), takes the local head and goes down 3 commits. Change the entries to “squash” and include in the check in.
After that, “:wq” to write the changes if using vi, git commit and merge with your upstream repo.
The Google search results in a simpler explanation: “ Use git rebase -i <after-this-commit> and replace “pick” on the second and subsequent commits with “squash” or “fixup”, as described in the manual.”