* fatal: ambiguous argument 'HEAD^': unknown revision or path not in the working tree.
@ 2010-10-28 13:09 Todd Wells
2010-10-28 13:41 ` SZEDER Gábor
` (3 more replies)
0 siblings, 4 replies; 15+ messages in thread
From: Todd Wells @ 2010-10-28 13:09 UTC (permalink / raw)
To: git
I was using GitX to prepare a commit. Something happened -- I don't
know what -- and suddenly my branch only had a single commit
in it that appears to contain all the files in my tree. So I went to the
command line and did this:
$ git reset --soft HEAD^
fatal: ambiguous argument 'HEAD^': unknown revision or path not
in the working tree.
When I do 'git log' in this branch, there's only one commit. Now, I
had many commits in this branch a few minutes ago. I really,
really, don't want to lose this.
What steps should I take to attempt to recover?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: fatal: ambiguous argument 'HEAD^': unknown revision or path not in the working tree.
2010-10-28 13:09 fatal: ambiguous argument 'HEAD^': unknown revision or path not in the working tree Todd Wells
@ 2010-10-28 13:41 ` SZEDER Gábor
2010-10-28 13:42 ` Mathias Lafeldt
` (2 subsequent siblings)
3 siblings, 0 replies; 15+ messages in thread
From: SZEDER Gábor @ 2010-10-28 13:41 UTC (permalink / raw)
To: Todd Wells; +Cc: git
Hi Todd,
On Thu, Oct 28, 2010 at 01:09:08PM +0000, Todd Wells wrote:
> I was using GitX to prepare a commit. Something happened -- I don't
> know what -- and suddenly my branch only had a single commit
> in it that appears to contain all the files in my tree. So I went to the
> command line and did this:
>
> $ git reset --soft HEAD^
> fatal: ambiguous argument 'HEAD^': unknown revision or path not
> in the working tree.
>
> When I do 'git log' in this branch, there's only one commit. Now, I
> had many commits in this branch a few minutes ago. I really,
> really, don't want to lose this.
>
> What steps should I take to attempt to recover?
Take a look at 'gitk yourbranch@{1}' or 'git log yourbranch@{1}'. If
it looks like your branch's lost history, then you can recover from
this situation with 'git reset --hard yourbranch@{1}'.
You can read up about the details here:
http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#recovering-lost-changes
HtH,
Gábor
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: fatal: ambiguous argument 'HEAD^': unknown revision or path not in the working tree.
2010-10-28 13:09 fatal: ambiguous argument 'HEAD^': unknown revision or path not in the working tree Todd Wells
2010-10-28 13:41 ` SZEDER Gábor
@ 2010-10-28 13:42 ` Mathias Lafeldt
2010-10-28 13:42 ` Santi Béjar
2015-09-09 8:34 ` davilda_
3 siblings, 0 replies; 15+ messages in thread
From: Mathias Lafeldt @ 2010-10-28 13:42 UTC (permalink / raw)
To: Todd Wells; +Cc: git
Todd Wells wrote:
> I was using GitX to prepare a commit. Something happened -- I don't
> know what -- and suddenly my branch only had a single commit
> in it that appears to contain all the files in my tree. So I went to the
> command line and did this:
>
> $ git reset --soft HEAD^
> fatal: ambiguous argument 'HEAD^': unknown revision or path not
> in the working tree.
>
> When I do 'git log' in this branch, there's only one commit. Now, I
> had many commits in this branch a few minutes ago. I really,
> really, don't want to lose this.
>
> What steps should I take to attempt to recover?
Check if you can reset your HEAD to a previous state saved in your
(local) reflog.
See section "RefLog Shortnames" in http://progit.org/book/ch6-1.html
-Mathias
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: fatal: ambiguous argument 'HEAD^': unknown revision or path not in the working tree.
2010-10-28 13:09 fatal: ambiguous argument 'HEAD^': unknown revision or path not in the working tree Todd Wells
2010-10-28 13:41 ` SZEDER Gábor
2010-10-28 13:42 ` Mathias Lafeldt
@ 2010-10-28 13:42 ` Santi Béjar
[not found] ` <AANLkTi=QODz+Gf9hwrdu6b900CzuO-BBnF2zmLWOGFpy@mail.gmail.com>
2015-09-09 8:34 ` davilda_
3 siblings, 1 reply; 15+ messages in thread
From: Santi Béjar @ 2010-10-28 13:42 UTC (permalink / raw)
To: Todd Wells; +Cc: git
On Thu, Oct 28, 2010 at 3:09 PM, Todd Wells <ttopwells@gmail.com> wrote:
> I was using GitX to prepare a commit. Something happened -- I don't
> know what -- and suddenly my branch only had a single commit
> in it that appears to contain all the files in my tree. So I went to the
> command line and did this:
>
> $ git reset --soft HEAD^
> fatal: ambiguous argument 'HEAD^': unknown revision or path not
> in the working tree.
>
> When I do 'git log' in this branch, there's only one commit. Now, I
> had many commits in this branch a few minutes ago. I really,
> really, don't want to lose this.
>
> What steps should I take to attempt to recover?
You could try:
git log -g
which will show you the reflog, a log of recent tip commits of HEAD.
You could also try to see other local branches and their reflog.
If all this fails you can:
git fsck --unreachable
that will output all the unreachable commits/objects, those not in
your branches or reflogs.
Once you have the correct commit you can reset the HEAD to this commit:
git reset HEAD
(or with --hard as necessary).
HTH,
Santi
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: fatal: ambiguous argument 'HEAD^': unknown revision or path not in the working tree.
2010-10-28 13:09 fatal: ambiguous argument 'HEAD^': unknown revision or path not in the working tree Todd Wells
` (2 preceding siblings ...)
2010-10-28 13:42 ` Santi Béjar
@ 2015-09-09 8:34 ` davilda_
2015-09-09 9:20 ` Jeff King
3 siblings, 1 reply; 15+ messages in thread
From: davilda_ @ 2015-09-09 8:34 UTC (permalink / raw)
To: git
Hi,
i'm new with git and i just want to cancel a commit. I just do git add and
git commit.
How can i canceled a commit in my case.
Best regards
--
View this message in context: http://git.661346.n2.nabble.com/fatal-ambiguous-argument-HEAD-unknown-revision-or-path-not-in-the-working-tree-tp5682535p7639207.html
Sent from the git mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: fatal: ambiguous argument 'HEAD^': unknown revision or path not in the working tree.
2015-09-09 8:34 ` davilda_
@ 2015-09-09 9:20 ` Jeff King
2015-09-09 16:24 ` Junio C Hamano
0 siblings, 1 reply; 15+ messages in thread
From: Jeff King @ 2015-09-09 9:20 UTC (permalink / raw)
To: davilda_; +Cc: git
On Wed, Sep 09, 2015 at 01:34:03AM -0700, davilda_ wrote:
> i'm new with git and i just want to cancel a commit. I just do git add and
> git commit.
> How can i canceled a commit in my case.
Usually with "git reset HEAD^". But I'm guessing from your subject line
that you tried that, and it did not work because this commit is the
_only_ commit in your repository (and "HEAD^", which means "the parent
commit of HEAD", does not make any sense, as there is no parent).
Annoyingly, I don't think there is an easy way with the current tools to
handle this corner case (you want to not reset to a commit, but back to
the "unborn branch" state).
The "simplest" way to do that is:
rm .git/refs/heads/master
but that is not guaranteed to work in future versions of git, and I
wouldn't recommend it in general.
Probably a better workflow is to create the commit state you _do_ want
(change files, "git add" them, etc), and then run "git commit --amend"
to replace the bad commit.
-Peff
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: fatal: ambiguous argument 'HEAD^': unknown revision or path not in the working tree.
2015-09-09 9:20 ` Jeff King
@ 2015-09-09 16:24 ` Junio C Hamano
0 siblings, 0 replies; 15+ messages in thread
From: Junio C Hamano @ 2015-09-09 16:24 UTC (permalink / raw)
To: Jeff King; +Cc: davilda_, git
Jeff King <peff@peff.net> writes:
> The "simplest" way to do that is:
>
> rm .git/refs/heads/master
>
> but that is not guaranteed to work in future versions of git, and I
> wouldn't recommend it in general.
Yeah, "git checkout -b" has a stronger sibling "git checkout -B"
(i.e. I know that the named branch already exists, so this is not a
request to create a new one, but to repoint that existing one), but
there is no analogue for "git checkout --orphan". That could be
worked around with something like this though:
$ git checkout --orphan hu
$ git branch -D master
$ git checkout --orphan master
As I agree with your "amending is better", I do not think allowing
an easier access to such a feature is urgent or important, though.
> Probably a better workflow is to create the commit state you _do_ want
> (change files, "git add" them, etc), and then run "git commit --amend"
> to replace the bad commit.
^ permalink raw reply [flat|nested] 15+ messages in thread
* fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
@ 2007-06-08 10:08 Thomas Glanzmann
2007-06-08 10:15 ` Junio C Hamano
0 siblings, 1 reply; 15+ messages in thread
From: Thomas Glanzmann @ 2007-06-08 10:08 UTC (permalink / raw)
To: GIT
Hello,
(s017241) [/usr/src/linux-2.6] git checkout v2.6.20
warning: You appear to be on a branch yet to be born.
warning: Forcing checkout of v2.6.20.
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions
Cannot detach HEAD
(s017241) [/usr/src/linux-2.6] git version
git version 1.5.2.1
what is going wrong here?
Thomas
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
2007-06-08 10:08 fatal: ambiguous argument 'HEAD': " Thomas Glanzmann
@ 2007-06-08 10:15 ` Junio C Hamano
2007-06-08 10:21 ` Thomas Glanzmann
2007-06-08 10:27 ` Junio C Hamano
0 siblings, 2 replies; 15+ messages in thread
From: Junio C Hamano @ 2007-06-08 10:15 UTC (permalink / raw)
To: Thomas Glanzmann; +Cc: GIT
Thomas Glanzmann <thomas@glanzmann.de> writes:
> Hello,
>
> (s017241) [/usr/src/linux-2.6] git checkout v2.6.20
> warning: You appear to be on a branch yet to be born.
> warning: Forcing checkout of v2.6.20.
> fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
> Use '--' to separate paths from revisions
> Cannot detach HEAD
>
> (s017241) [/usr/src/linux-2.6] git version
> git version 1.5.2.1
>
> what is going wrong here?
Perhaps repository was set up in an unusual way by hand
(i.e. not by a clone), such that:
1. you have HEAD pointing at a branch (e.g. 'refs/heads/master'),
2. which does _not_ exist yet (i.e. no 'refs/heads/master'),
3. yet you have a tag that you can try to detach your HEAD to (e.g. v2.6.20).
... well that was my initial guess, but even after setting up such a
funny repository by hand, I cannot seem to reproduce it.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
2007-06-08 10:15 ` Junio C Hamano
@ 2007-06-08 10:21 ` Thomas Glanzmann
2007-06-08 10:33 ` Junio C Hamano
2007-06-08 10:27 ` Junio C Hamano
1 sibling, 1 reply; 15+ messages in thread
From: Thomas Glanzmann @ 2007-06-08 10:21 UTC (permalink / raw)
To: Junio C Hamano; +Cc: GIT
Hello Junio,
> ... well that was my initial guess, but even after setting up such a
> funny repository by hand, I cannot seem to reproduce it.
This was on a fresh clone. What I did was:
(s017241) [/usr/src] git clone 131.188.30.102:/scratch/tg/linux-2.6/
Initialized empty Git repository in /usr/src/linux-2.6/.git/
remote: Generating pack...
remote: Done counting 496189 objects.
remote: Deltifying 496189 objects...
remote: 100% (496189/496189) done
Indexing 496189 objects...
remote: Total 496189 (delta 401610), reused 496189 (delta 401610)
100% (496189/496189) done
Resolving 401610 deltas...
100% (401610/401610) donedone
fatal: Not a valid object name HEAD
I see it. Last line. I tried to clone from a repository which itself had a
detached HEAD. Could that be the problem?
Thomas
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
2007-06-08 10:21 ` Thomas Glanzmann
@ 2007-06-08 10:33 ` Junio C Hamano
2007-06-08 10:38 ` Thomas Glanzmann
0 siblings, 1 reply; 15+ messages in thread
From: Junio C Hamano @ 2007-06-08 10:33 UTC (permalink / raw)
To: Thomas Glanzmann; +Cc: GIT
Thomas Glanzmann <thomas@glanzmann.de> writes:
> I see it. Last line. I tried to clone from a repository which itself had a
> detached HEAD. Could that be the problem?
Ah, our mails crossed.
There is no reason to forbid cloning of a repository whose HEAD
is detached, but detached HEAD is a relatively recent invention,
and I would not be surprised if that was indeed the breakage,
nor nobody has hit this so far.
It's sufficiently late here so I do not think I would be able to
take a look at it tonight, though. Sorry.
Just in case you need unblocking (although I think you know how
already), you should be able to continue with:
$ git rev-parse v2.6.20^0 >.git/HEAD
$ git read-tree HEAD
$ git checkout-index -f -q -u -a
That would give you a normal detached state at v2.6.20; you
should be able to come back to your branches with usual "git
checkout".
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
2007-06-08 10:15 ` Junio C Hamano
2007-06-08 10:21 ` Thomas Glanzmann
@ 2007-06-08 10:27 ` Junio C Hamano
2007-06-10 8:54 ` carbonated beverage
1 sibling, 1 reply; 15+ messages in thread
From: Junio C Hamano @ 2007-06-08 10:27 UTC (permalink / raw)
To: Thomas Glanzmann; +Cc: GIT
Junio C Hamano <gitster@pobox.com> writes:
> Perhaps repository was set up in an unusual way by hand
> (i.e. not by a clone), such that:
>
> 1. you have HEAD pointing at a branch (e.g. 'refs/heads/master'),
> 2. which does _not_ exist yet (i.e. no 'refs/heads/master'),
> 3. yet you have a tag that you can try to detach your HEAD to (e.g. v2.6.20).
>
> ... well that was my initial guess, but even after setting up such a
> funny repository by hand, I cannot seem to reproduce it.
Actually, that turns out to be the reason for 'maint' releases,
although it works on 'master' (hence will be in 1.5.3 later).
How did you get your repository into such a state to begin with?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
2007-06-08 10:27 ` Junio C Hamano
@ 2007-06-10 8:54 ` carbonated beverage
0 siblings, 0 replies; 15+ messages in thread
From: carbonated beverage @ 2007-06-10 8:54 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Thomas Glanzmann, GIT
On Fri, Jun 08, 2007 at 03:27:30AM -0700, Junio C Hamano wrote:
> How did you get your repository into such a state to begin with?
It's kinda odd to see this thread, as I hit this issue today, as well.
If you need another test case, the cvsps git repo shows this too:
ramune/lycaeum:git: git clone http://ydirson.free.fr/soft/git/cvsps.git
<snip checkout messages>
ramune/lycaeum:git: cd cvsps
ramune/lycaeum:cvsps: ls
ramune/lycaeum:cvsps: git checkout -f
warning: You appear to be on a branch yet to be born.
warning: Forcing checkout of HEAD.
fatal: just how do you expect me to merge 0 trees?
ramune/lycaeum:cvsps: cat .git/HEAD
ref: refs/heads/master
ramune/lycaeum:cvsps: ls .git/refs/head/master
ls: .git/refs/head/master: No such file or directory
-- DN
Daniel
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2015-09-09 16:25 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-28 13:09 fatal: ambiguous argument 'HEAD^': unknown revision or path not in the working tree Todd Wells
2010-10-28 13:41 ` SZEDER Gábor
2010-10-28 13:42 ` Mathias Lafeldt
2010-10-28 13:42 ` Santi Béjar
[not found] ` <AANLkTi=QODz+Gf9hwrdu6b900CzuO-BBnF2zmLWOGFpy@mail.gmail.com>
2010-10-28 14:01 ` Santi Béjar
2015-09-09 8:34 ` davilda_
2015-09-09 9:20 ` Jeff King
2015-09-09 16:24 ` Junio C Hamano
-- strict thread matches above, loose matches on Subject: below --
2007-06-08 10:08 fatal: ambiguous argument 'HEAD': " Thomas Glanzmann
2007-06-08 10:15 ` Junio C Hamano
2007-06-08 10:21 ` Thomas Glanzmann
2007-06-08 10:33 ` Junio C Hamano
2007-06-08 10:38 ` Thomas Glanzmann
2007-06-08 10:27 ` Junio C Hamano
2007-06-10 8:54 ` carbonated beverage
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).