Skip to content

Comment on Git in six hundred words

Comments

What git needs is a simple undo command, as in

    git undo
and it just undoes whatever you just did. There seems to be a way to undo pretty much anything, but I usually end up googling and deciphering the likes of
    git reset HEAD hard -f --now origin/master --no-rebase %${%&`+'${`%&NO CARRIER") 
Then when that goes wrong, you're in real trouble and left scratching your head at git's error message.

Hmm, the reflog usually (always?) provides all the info you need to undo the last action. I wouldn't be surprised if it were possible to build a "git undo" command on top of that. The fact that no one has yet done so is a great illustration of your point, though.

The reflog just lets you undo commits (whether created by `git commit` or rebase or merge or whatever), while actions like `git reset`, `git checkout`, `git add`, `git gc`, and `git rm` cannot be undone with the reflog.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.