Git

Undo Add

The opposite instruction of add (staging files) is reset (unstaging files). Use git reset FILE to just unstage FILE or git reset to unstage everything.

!!! example shell git add main.py git reset main.py

Undo Commit

To undo the last commit without resetting the worktree and index use git reset --soft HEAD^ which is equivalent to git reset --soft HEAD~1

!!! example shell git commit -m "Add something" git reset --soft HEAD^ git commit -a -c ORIG_HEAD

Soft vs. Mixed vs. Hard Reset

References