Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

19
  • 64
    As a more visual and nicer alternative to reflog for this purpose, I like to use git log --graph --decorate --oneline $(git rev-list -g --all). It shows a tree of all commits, including dangling unnamed branches Commented Jun 22, 2015 at 18:02
  • 2
    Lets say I have a directory with existing files in it. In this directory I run git init, and then right after that git reset --hard. There is no reflog, or even any logs to begin with. Are these files pretty much toast now? Commented Jul 27, 2015 at 16:24
  • 5
    git reset HEAD~12 oops... git reset HEAD@{12} nooo .. 'git reflog' to the rescue! oh it's just git reset HEAD@{1} Commented Sep 16, 2015 at 19:35
  • 4
    Trying out the "short answer" (copy & paste), I got the following error: fatal: ambiguous argument ''HEAD@{1}'': unknown revision or path not in the working tree. Resolved by omitting the quotation marks around HEAD@{1}. Commented Jan 13, 2020 at 15:39
  • 1
    works for undoing git reset --soft HEAD~1, and after running git reset 'HEAD@{1}', the stage area is clean too. Commented Aug 12, 2021 at 8:15