How can I squash my last X commits together into one commit using Git?
How can I squash my last X commits together into one commit using Git?
git rebase -i HEAD~X
The following content will be shown:
pick 1bffc15c My earlier commit
pick 474bf0c2 My recent commit
# ...
For the commits that you want to squash, replace pick with fixup, so it becomes:
pick 1bffc15c My earlier commit
fixup 474bf0c2 My recent commit
# ...
If it's open in vim (default interface within terminal), then press Esc
on your keyboard, type :wq
and Enter
to save the file.
Verify: Check git log