Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 509
morfys Avatar asked Oct 15 '12 16:10

morfys


2 Answers

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^"
like image 60
Ena Avatar answered Oct 22 '22 21:10

Ena


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

like image 36
Adam Dymitruk Avatar answered Oct 22 '22 23:10

Adam Dymitruk