Skip to content

Instantly share code, notes, and snippets.

@Justinzobel
Created October 25, 2023 07:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Justinzobel/dc60904e3b3c94845c2113e084ff8269 to your computer and use it in GitHub Desktop.
Save Justinzobel/dc60904e3b3c94845c2113e084ff8269 to your computer and use it in GitHub Desktop.
Git Squash Commits Locally

4 is the number of commits you want to squash

git rebase -i origin/master~4 branch_name

This will open your edit, replace the pick with squash on the commits you want to squash into the main commit.

The editor will open again and you need to comment out all commit messages that you don't want.

git push -f git push origin +branch_name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment