Ambiguous argument in git reset

I recently screwed up a git rebase -i, and so I wanted to do a git reset --hard HEAD@{5}.

However, doing a git reset --hard HEAD@{5} or git log HEAD@{5} caused the following error message to be shown:

fatal: ambiguous argument 'HEAD@{5}': unknown revision or path not in the working tree.

Then, I decided to specify the hash key corresponding to HEAD@{5} shown in git reflog instead. For instance:

git reset --hard e8be841

In doing so, was there any risk screwing up the git repository or doing something unexpected?

  • Git checkout from repository on GitHub into an existing local repository based on SVN
  • git autocrlf input does convert line-endings but from LF to CRLF?
  • Version Control for analytic projects
  • Creating a submodule in a git project
  • Which is official GUI of Git for windows?
  • Why Kiln is based on Mercurial, and not other (D)VCS
  • Visual Studio Website Reference Paths
  • What makes some version control systems better at merging?
  • 3 Solutions collect form web for “Ambiguous argument in git reset”

    Git is very forgiving in how it does merges and rebases. If you look at the git repository’s file structure during one of those operations, you will see that it alters files designated to help with those operations and does not unsafely change core objects. If it does, it’s in an additive manner.

    So there is practically no chance of doing any damage to your repository. As an example, take another repo, make a copy, start a rebase and then compare the .git folders in both.

    P.S. as per the comment on your question, yes, do use git rebase --abort

    For me the problem was I needed to put the double quotes on Windows command prompt.

    Instead of:

    git reset --soft 'HEAD^' 

    I had to write:

    git reset --soft "HEAD^"

    Git has some shell argument quoting issues.

    Try git log 'HEAD@{5}' instead.

    In my case I get the error fatal: Log .git/logs/HEAD is empty..

    The next workaround for this is:

    git log HEAD^^^^^

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