Git Squash is a process of welding / consolidating a range of commits in series. Best practice is to create a topic branch and do as many commits during development. In many cases interim commits are not necessary and have little value.
Suppose 3 skills entries need to be added in some job description; viz. Git, Python and Ruby. During development author might as well write this in 3 commits. But while pushing to github / git server it doesn't makes sense to push 3 commits.
An official way to squash commits is Interactive rebase. This is undoubtedly an excellent facility to squash commits and many more tasks like reword, re arrange etc.
However it works only on native git and not on Jgit implementation (eclipse etc) and has a bit of a learning curve.
Here is an alternative way to squash commit using git reset (mixed)
Squash to 3 commits in a single commit.
git reset HEAD~3
This will show as though you have not committed following commits.
HEAD HEAD~1 HEAD~2
Your changes are intact in consolidated fashion. If you have added a new file you need to add it again.
Verify that all changes are intact.
git add file_name git commit -m “consolidated commit”
Now You have a consolidated (aka Squashed Commit) without using git rebase interactive.