- Start with a clean branch. Check using git status
git status On branch main Your branch is up to date with 'origin/main'. nothing to commit, working tree clean
- Delete the commits locally
Replace X with the number of commits to delete, e.g. 1git reset --hard HEAD~X
- Delete the commits from the remote repository
git push origin HEAD --force
Remove commits from remote repository
A quick how to guide on how to remove commits from a remote repository