Thu, 12/10/2020 - 08:46
Git add
When running git add
you can undo the previous command with git reset
.
**Option 1 - git restore
**
git restore --staged <file>
Option 2 - git reset
git reset <file>
or to reset everything
git reset
Git commit
When running git commit
you can undo the previous commit as explained below
-
git reset --soft HEAD~
will undo the last commit. -
git reset HEAD~
will undo the last commit and unstage all files (undo commit + undo git add) -
git reset --mixed HEAD~
will undo commit and unstage all files -
git reset --hard HEAD~
undo the commit unstage all files and discard all changes
Authored by