← Back
git

Undo git

TIL #

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