1

In Git after last push to remote repo I worked on master branch. I have 6 commits to push now. I want to squash these 6 into 1 commit message then do push.

Any suggestion?

αƞjiβ
  • 3,056
  • 14
  • 58
  • 95

1 Answers1

3

If you are ok with writing a new commit message

git reset --soft HEAD~6
git commit

This will the last 6 commits and put them back in the staging area. The subsequent commit will then include all the changes.

If you instead want to preserve the commit messages

git rebase -i HEAD~6

and in the interactive editor, replace 'pick' with 'fixup' for the last 5 commits.

This will create a unique commit, containing all the 6 commit messages.

Gabriele Petronella
  • 106,943
  • 21
  • 217
  • 235