Whenever you want to squash last commits in a single commit:-
first check your log
git log
count number of commits to be squashed. Let the number of commits be x
open rebase window using HEAD
git rebase -i HEAD~x
Note the SHA commit value of the oldest commit from where you have to start squashing
open rebase window using SHA value
git rebase -i <first 7 alphnumerics of SHA>
Follow the instruction and make the changes accordingly
press esc key
type :x!
press return key
write your final commit message
press esc again
type :wq! or :x!
press return key
you have to push changes forcefully
git push -f origin master
replace 'origin' with your remote name and 'master' with your branch name.
Squash it up ;)
Wahhh !!! We needed it .