Skip to content

Squash commits

Benjamin Bay edited this page Nov 21, 2019 · 5 revisions

How to squash your commits from the terminal before merging:

  1. Make sure your branch is up to date with the current develop branch: git pull origin develop.
  2. Run git rebase -i develop.
  3. You should see a list of commits, each commit starting with the word "pick".
  4. Make sure the first commit says "pick" and change the rest from "pick" to "squash" -- this will squash that commit into the previous one.
  5. Save and close the editor twice (It will give you the opportunity to change the commit message).
  6. 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.

Clone this wiki locally