How to revert an unnecessary “git reset HEAD~1”

After running git reset HEAD~1, I noticed that actually there was nothing else to do and the commit was fine. Is there a way to revert this command?

  • Why is not recommended to have an Eclipse project folder as a Git repository?
  • Delete and Redeploy Rails app to heroku
  • Adding Git to PATH Variable - Can't find GitHub under AppData/Local
  • What does “!eol” in gitattributes do?
  • .gitignore and Visual Studio project: Ignore bin/Debug directory but not bin/Release directory
  • git - confusion over terminology, “theirs” vs “mine”
  • How to add a non-npm dependency to my package.json?
  • Mac OS X PHP IDE with Git support
  • How do you push a Git tag to a branch using a refspec?
  • Keeping track of source code variants
  • Visual Studio 2013 Team Explorer/Git integration missing files
  • Git issue with Visual Studio 2015
  • 3 Solutions collect form web for “How to revert an unnecessary “git reset HEAD~1””

    You can use:

    git reset HEAD@{1}

    This uses the last entry in the reflog. See git reflog if you did other things in between.

    You could see the commit id of that commit with git reflog.

    Even easier (if you haven’t done any other operations):

    git reset ORIG_HEAD

    ORIG_HEAD is the previous state of HEAD.

    More details about HEAD vs. ORIG_HEAD are in the answer to this SO question.

    Git Baby is a git and github fan, let's start git clone.