Delete all commit history in GitHubΒΆ
Source : StackOverflow
Warning
Deleting the .git
folder and initializing a new repository may cause problems in the git repository.
To delete all the commit history but keep the code in current state, follow the steps below.
- Checkout
git checkout --orphan latest_branch
- Add all 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
- Force update the repository
git push -f origin main
- Housekeeping
git gc --aggressive --prune=all