Git Undo and Reflog
Discussions center on Git's recovery features like reflog, reset, revert, and the debate over needing a simpler 'git undo' command versus trusting existing tools to prevent permanent data loss.
Activity Over Time
Top Contributors
Keywords
Sample Comments
You shouldn't be able to lose any committed work in git. If you botch a merge, you can reset to one of the merge parents and try it again. If you botch a "destructive" operation like a reset or a rebase, you can undo it using the reflog, which is essentially a 30-day undo history for every branch in your repository.
Isn't that what git reflog + reset are for?
This seems like putting a training wheel on a training wheel. git is already the easiest to understand of any VCS that I've used, and it's somewhat hard to do something in git that can't be reversed. As the articles states, it's unlikely you'll ever lose your changes. Further, this doesn't seem to be that different of a concept from git reset, so why not learn reset instead of yet another command?
Good modern software always offers an undo option. Where is "git undo"?
whoa. well, if it really works for you. The thing is, git has practically zero "destructive" commands, you almost always (unless you called garbage collector aggressively) return to the previous state of anything committed to it. `git reflog` is a good starting point.I think i've seen someone coded user-friendlier `git undo` front for it.
It's needed when you're somebody who doesn't want to spend their life in git and just want to undo a mistake.
What's wrong with git revert?
No need to make a "backup" branch. Learn to trust the reflog.
Unlike an exploding car, Git has undo. See git reflog.
Reflog to the rescue: https://git-scm.com/docs/git-reflog