xxxxxxxxxx
# --soft option preserves your files
$ git reset --soft HEAD~1
xxxxxxxxxx
$ git commit -m "Something terribly misguided" # (0: Your Accident)
$ git reset HEAD~ # (1)
[ edit files as necessary ] # (2)
$ git add . # (3)
$ git commit -c ORIG_HEAD # (4)
xxxxxxxxxx
File > Other Settings > Settings for New Project > Version Control > Confirmation > When files are created > Do not add
xxxxxxxxxx
# Option 1: Create a new commit that undoes the last commit
git revert HEAD
# Option 2: If you need to undo a specific commit by its hash
git revert <commit-hash>
# Option 3: If you need to undo multiple commits
git revert HEAD~3..HEAD # Reverts the last 3 commits