Delete all commits from git branch
Create a new blank branch (NEW_BRANCH
)
git checkout --orphan NEW_BRANCH
git rm -rf .
Add a single file (need to have a commit)
touch README.md
git add README.md
git commit -m "initial"
Delete the branch you want to remove (OLD_BRANCH
)
git branch -D OLD_BRANCH
Rename the current branch (NEW_BRANCH
) to the deleted branch (OLD_BRANCH
)
git branch -m OLD_BRANCH
Push your changes
git push -f origin OLD_BRANCH