Skip to content

Instantly share code, notes, and snippets.

@bbottema
Last active November 27, 2023 21:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbottema/4d6d799b9e2f018ad487df8c4a6973db to your computer and use it in GitHub Desktop.
Save bbottema/4d6d799b9e2f018ad487df8c4a6973db to your computer and use it in GitHub Desktop.
Truncate GIT history
# <commit-rev> = commit you want to reset repo to
# <target-branch> = branch you want to truncate (probably master or develop)
git checkout --orphan temp <commit-rev>
git commit -m "Truncate history or Initial commit"
git rebase --onto temp <commit-rev> <target-branch>
git push --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment