Steps to squash multiple commits in Terminal using Vim
git rebase -i HEAD~5
(5 or however many commits you had, differing from master)- Put the cursor highlight on the SECOND commit using your arrow keys.
- To enable visual block, do
CRTL + V
- Use DOWN arrow keys to highlight
pick
for each commit (not including the commit you want to squash the other commits into). - Press
f
for fixup (ors
forsquash
- this depends on the command you want to use) - Exit visual mode by pressing
Esc
. - When you do
:wq
to exit Vim, thefixup
s will be filled in for you automatically, removing the need to do it manually for each commit.
More reading: Atlassian Git Rebase