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.

12
  • 292
    You can use "git reset --hard HEAD@{1}", no need for using SHA1. In most cases it should be enough to use "git reset --hard ORIG_HEAD". Commented May 21, 2009 at 6:17
  • 50
    git log -g can be a little bit nicer way to view the reflog than git reflog. Commented Oct 28, 2010 at 13:09
  • 92
    There's one very important caveat with this.. and thats the "--hard" part. --hard blows away your local uncommitted changes. And you cant get them back like this (as they've not been committed anywhere). I believe there is nothing you can do about that :( Commented Aug 4, 2011 at 5:05
  • 9
    ^ Just so you know you can stash your local changes before doing a reset --hard, and then just pop them and you lose nothing! Gotta love git.
    – Lethjakman
    Commented Sep 1, 2014 at 2:49
  • 9
    I prefer git reflog over git log -g simply because you get all the information on one line with sha1, HEAD info and commit messages all lined up. Much easier to read.
    – Snowcrash
    Commented Nov 11, 2014 at 18:41