How to delete entire git commit history?

Axorax - Jul 26 - - Dev Community

I have deleted my git commit history plenty of times just to make my repository look "clean" (roast me in the comments for it). It's probably best to not do this but I will still share how to do it.

Delete entire commit history

git checkout --orphan latest_branch
Enter fullscreen mode Exit fullscreen mode
git add -A
Enter fullscreen mode Exit fullscreen mode
git commit -am "commit message"
Enter fullscreen mode Exit fullscreen mode
git branch -D main
Enter fullscreen mode Exit fullscreen mode
git branch -m main
Enter fullscreen mode Exit fullscreen mode
git push -f origin main
Enter fullscreen mode Exit fullscreen mode

I did not figure this out myself or anything. I got it from here -> https://stackoverflow.com/questions/13716658/how-to-delete-all-commit-history-in-github

It's by Desta Haileselassie Hagos, later edited by creyD

. . . . . . . .
Terabox Video Player