cvod3a
Last Updated: February 25, 2016
·
725
· riyadhalnur
10309058 10152457564452360 4465802230248535815 n

Git Squash Commits

To reduce the number of commits in Git when rebasing/merging with another branch or sending in a pull request, you can this Git command to 'squash' the number of commits -

git rebase -i HEAD~[number_of_commits]

For example -

git rebase -i HEAD~2

This will squash/merge/rebase the latest 2 commits in the HEAD branch.

Say Thanks
Respond

2 Responses
Add your response

16311
Vraa

Well, I believe that command won't squash by itself. After running that command, you'll be prompted with a editor screen where you can do couple of operations and one of them is squashing commits.

over 1 year ago ·
16315
10309058 10152457564452360 4465802230248535815 n

yes it will open up a interactive session where you can choose the commits to keep which technically is squashing and since we are passing it a number, it will only pull up the specified number of commits in the session

over 1 year ago ·
Filed Under