Git Remove All Commits
Clean up history from a repository by removing the git commits and replacing it with a new single commit.
- Create a temporarily branch disconnected from all the other branches and commits:
git checkout --orphan temp_branch
- Add the files to new temporarily branch:
git add -A
- Commit the changes:
git commit -am "First commit"
- Delete the main branch:
git branch -D master
- Rename temporarily branch to the main branch:
git branch -m master
- Force push the new main branch:
git push -f origin master