Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save albertodebortoli/d4a254bfe959975ae95266b799c8bb7d to your computer and use it in GitHub Desktop.
Save albertodebortoli/d4a254bfe959975ae95266b799c8bb7d to your computer and use it in GitHub Desktop.
Truncate git history
https://stackoverflow.com/questions/41953300/how-to-delete-the-old-git-history
git checkout --orphan temp <f> # checkout to the status of the git repo at commit f; creating a branch named "temp"
git commit -m "new root commit" # create a new commit that is to be the new root commit
git rebase --onto temp <f> master # now rebase the part of history from <f> to master onthe temp branch
git branch -D temp # we don't need the temp branch anymore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment