Skip to content

Instantly share code, notes, and snippets.

@un4ckn0wl3z
Created October 30, 2023 10:00
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 un4ckn0wl3z/af33c93c26dee5d6ec8bf70f8070ddb6 to your computer and use it in GitHub Desktop.
Save un4ckn0wl3z/af33c93c26dee5d6ec8bf70f8070ddb6 to your computer and use it in GitHub Desktop.
git.orphan
Deleting the .git folder may cause problems in your git repository. If you want to delete all your commit history but keep the code in its current state, it is very safe to do it as in the following:
Checkout
git checkout --orphan latest_branch
Add all the files
git add -A
Commit the changes
git commit -am "commit message"
Delete the branch
git branch -D main
Rename the current branch to main
git branch -m main
Finally, force update your repository
git push -f origin main
PS: this will not keep your old commit history around
ref: https://stackoverflow.com/questions/13716658/how-to-delete-all-commit-history-in-github
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment