-1

I actually want to squash around 5-6 commits in a single commit. What is the best option I have in this case?

2

1 Answer 1

4

With the most recent commit checked out, do a soft reset to your desired parent commit. If the commits are linear, The parent of the last N commits is HEAD~N. For example, to combine the last five commits:

git reset --soft HEAD~5

Optionally, make sure you've got the right changes with git status or git diff.

Then create the new commit:

git commit -m 'five combined commits in one'

Not the answer you're looking for? Browse other questions tagged or ask your own question.