Created
March 13, 2025 19:00
-
-
Save TitusRobyK/0df86adaefc184fe5f344453eeaf18b5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Count the Commits: Determine how many commits you want to squash (say 5). | |
Start Interactive Rebase: | |
Run the following command (replace 5 with the number of commits): | |
git rebase -i HEAD~5 | |
Mark Commits for Squashing: | |
An editor will open listing your commits. Keep the first commit as pick and change the rest from pick to squash (or s): | |
pick abc123 First commit message | |
squash def456 Second commit message | |
squash ghi789 Third commit message | |
squash jkl012 Fourth commit message | |
squash mno345 Fifth commit message | |
Edit the Commit Message: | |
After saving, another editor prompt will let you combine and edit the commit messages. Replace them with your new message, then save and exit. | |
Finalize: | |
The commits will be squashed into a single commit with your new commit message. If you’ve already pushed these commits, you’ll need to force push: | |
git push --force origin <branch-name> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment