Created
March 27, 2019 15:19
-
-
Save kolygri/d0e55a68fb2a7ec64dcb2efb37805c40 to your computer and use it in GitHub Desktop.
How to squash commits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Squashing commits before merging, to make the git history tidy. | |
Make sure your branch is up to date with the master branch. | |
Run git rebase -i master. | |
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 each commit into the previous commit, which will continue until every commit is squashed into the first commit. | |
Save and close the editor. | |
It will give you the opportunity to change the commit message. | |
Save and close the editor again. | |
Then you have to force push the final, squashed commit: git push -f. | |
If the repository is configured to reject force pushes you need to delete the remote branch and recreate it, | |
make sure nobody checked it out. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment