From: "SZEDER Gábor" <szeder@ira.uka.de>
To: Daly Gutierrez <daly.gutierrez@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Recovering Committed Changes in a Detached Head?
Date: Sat, 8 Oct 2011 23:37:41 +0200 [thread overview]
Message-ID: <20111008213741.GA24409@goldbirke> (raw)
In-Reply-To: <1318107488.5865.46.camel@R0b0ty>
Hi,
On Sat, Oct 08, 2011 at 04:58:07PM -0400, Daly Gutierrez wrote:
> Is this possible after changing from the Detached Head branch to an
> existing branch? How about if I don't remember the commit SHA1 ID?
>
> What I did, to the best of my knowledge:
> 1) Checked out a previous version:
> > git checkout 3a5bb38a83c00f7acab573f0ec836577143200aa
>
> 2) Modified file and committed the changes in the detached branch.
> > git log
> commit 92aa5381b9f7229523dba42aa94735c30f173451
> Author: Daly Gutierrez <Daly.Gutierrez@gmail.com>
> Date: Sat Oct 8 16:20:11 2011 -0400
>
> Committing this in the Detached Head
>
> 3) For curiosity,
> > git branch
> * (no branch)
> New_Branch
> Second_New_Branch
> master
>
> 4) Changed to 'New_Branch' branch... I no longer see the detached
> branch...
> > git branch
> * New_Branch
> Second_New_Branch
> master
>
> 5) Want to access the file with the changes I made in the Detached
> branch, but don't know how... PLEASE HELP?
git reflog to the rescue. For your example above it will output
something like this:
deadbeef HEAD@{0}: checkout: moving from 92aa5381b9f7229523dba42aa94735c30f173451 to New_Branch
92aa5381 HEAD@{1}: commit: Committing this in the Detached Head
3a5bb38a HEAD@{2}: checkout: moving from master to 3a5bb38a83c00f7acab573f0ec836577143200aa
deafbabe HEAD@{3}: ...
...
There you see the first line of the commit message from your "lost"
commit, and you can do
git checkout -b lost_detached_head 92aa5381
and you get a branch pointing to that commit you made while on
detached head, and you can work with it as usual.
Best,
Gábor
next prev parent reply other threads:[~2011-10-08 21:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-08 20:58 Recovering Committed Changes in a Detached Head? Daly Gutierrez
2011-10-08 21:37 ` SZEDER Gábor [this message]
2011-10-08 22:00 ` Martin Fick
2011-10-09 3:32 ` Joel C. Salomon
2011-10-09 5:39 ` Martin Fick
2011-10-09 5:52 ` Nguyen Thai Ngoc Duy
2011-10-09 7:46 ` Ronan Keryell
2011-10-09 8:12 ` Matthieu Moy
2011-10-09 23:22 ` Junio C Hamano
2011-10-10 1:26 ` Miles Bader
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111008213741.GA24409@goldbirke \
--to=szeder@ira.uka.de \
--cc=daly.gutierrez@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox