1. 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
  2. Delete the commits locally
    git reset --hard HEAD~X
    Replace X with the number of commits to delete, e.g. 1
  3. Delete the commits from the remote repository
    git push origin HEAD --force