Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Squashing commits: combining multiple existing commits

Example:

I have three commits on my branch for a single Jira ticket. I would like to squash them into a single commit before pushing to my branch and creating a pull request.

While on my branch, type:

git rebase -i HEAD~3

This will open the default editor on your machine and display something like the following:

pick afb581 IGBF-3379: Fix DAS annotations
pick 643d0e IGBF-3379: Fix typo 
pick 87871a IGBF-3379: Fix second typo

Note that the oldest commit is on top, and the newer commit is on the bottom.

To squash the two newer commits into the older commit, change pick to squash:

pick afb581 IGBF-3379: Fix DAS annotations
squash 643d0e IGBF-3379: Fix typo
squash 87871a IGBF-3379: Fix second typo
  • No labels