Undo git
TIL #
- Git keeps a log of all ref updates:
git reflog
- ORIG_HEAD references the commit that HEAD previously referenced.
Recipes #
Some recipes I have to look for everytime on internet. Trying to collect them all here (with the hope of improve my memory):
Undo last commit (local) #
Commit in a wrong branch, for example (source):
git reset HEAD~
# you can edit files
Undo the undo (source):
git reset 'HEAD@{1}'
# alternative
git reset ORIG_HEAD