[Git]: reset
git
09/24/2019
Deleting(undoing) the last commit
1. Undo commit keeping all files staged
BASH
git reset --soft HEAD~
2. Undo commit and un-stage all files
BASH
git reset HEAD~
3. Undo commit and completely remove all changes
BASH
git reset --hard HEAD~
Note
- HEAD~[Num]:
[Num]
is the number of commits to go backHEAD
: current commitHEAD~1
≣HEAD~
: 1 commit before
- Instead of
HEAD~*
, you can use commit id by logging withgit log --oneline
- i.e.
git reset --soft 858da45
- i.e.