Re: Recovering Committed Changes in a Detached Head?
- From
Joel C. Salomon <joelcsalomon@gmail.com>
- Date
- Oct 9, 2011, 03:32 UTC
- Message-ID
- <4E9115B0.3030701@gmail.com>
- In-Reply-To
- <ab706826-75df-4410-941e-6b40ec92713c@email.android.com>
On 10/08/2011 06:00 PM, Martin Fick wrote:
>> git reflog to the rescue.
<snip>
Show 11 quoted lines
>> 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. > > While rflog is cool, I can't help but think that git could be even more helpful for these scenarios. > > First, maybe git could create refs for these automatically, perhaps with a name like orphans/1? Maybe these refs would only be visible via git branch --orphans.
Creating these "orphan" refs would require the equivalent of (part of) git-fsck; I can't imagine that could be imposed without significant overhead on too many operations. I think you'd be better off wrapping git-fsck in a script that can create these branches.
--Joel