-
Notifications
You must be signed in to change notification settings - Fork 30
Squash commits
Benjamin Bay edited this page Nov 21, 2019
·
5 revisions
How to squash your commits from the terminal before merging:
- Make sure your branch is up to date with the current
developbranch:git pull origin develop. - Run
git rebase -i develop. - You should see a list of commits, each commit starting with the word "pick".
- Make sure the first commit says "pick" and change the rest from "pick" to "squash" -- this will squash that commit into the previous one.
- Save and close the editor twice (It will give you the opportunity to change the commit message).
- Finally, force push the final, squashed commit with
git push --force-with-lease origin.
Squashing commits can be a tricky process but once you figure it out, it's really helpful and keeps the repo concise and clean.