Skip to content

Instantly share code, notes, and snippets.

@gmolveau
Created April 25, 2022 13:25
Show Gist options
  • Save gmolveau/5721b9fd9e4b7b19c9f6afd1af19f729 to your computer and use it in GitHub Desktop.
Save gmolveau/5721b9fd9e4b7b19c9f6afd1af19f729 to your computer and use it in GitHub Desktop.
git reset / squash all commits in branch into one single commit
# source : https://stackoverflow.com/a/24154149
export BRANCH="main"
git checkout --orphan new-$BRANCH $BRANCH
git commit -m "Commit message that summaries all the commits"
# Overwrite the old branch reference with the new one
git branch -M new-$BRANCH $BRANCH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment