How do you recover a commit after `git reset --hard`?
IntermediateConceptUndoing changes: reset, revert, restore and reflog
Answer
The commit still exists until garbage collected. Find it in the reflog and point a branch to it.
git reflog
git reset --hard HEAD@{1}
# or
git branch recovered 3fa9c21
More on Undoing changes: reset, revert, restore and reflog
What are the three modes of `git reset`?BeginnerWhat is the difference between `git reset` and `git revert`?BeginnerHow do you discard changes in one file?BeginnerCan you recover uncommitted changes lost by `git reset --hard` or `git checkout .`?IntermediateWhat does `git commit --amend` do to the reflog and to the old commit?IntermediateHow do you undo `git add` for a file?Beginner