git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Casey Dahlin <cdahlin@redhat.com>, git@vger.kernel.org
Subject: Re: [PATCH] logging branch deletion to help recovering from mistakes
Date: Tue, 7 Dec 2010 14:55:26 -0600	[thread overview]
Message-ID: <20101207205526.GA25008@burratino> (raw)
In-Reply-To: <7vfwu9pbyj.fsf@alter.siamese.dyndns.org>

Junio C Hamano wrote:

> "git log -g HEAD"
> keeps track of what was at the tip of HEAD, be it pointing at a branch or
> pointing diretly at a commit in a detached state, no?

Yes.

1. Imagine I have an interesting branch and delete it:

	$ git branch interesting $(lots of hard work)
	$ git branch -D interesting

Oops.  If I want to recover that branch, I may have a lot of digging
to do in the HEAD reflog.  It may not be there are all.  Your patch
mitigates that by allowing a simple "I didn't mean that" command.

	$ git branch --undelete interesting

2. Great.  Another way to lose a line of development, as Casey
mentioned, is to not give it a branch name in the first place:

	$ git checkout HEAD^0
	...
	$ git checkout something-else

Oops.  Well, not so bad.  If I want to recover my old work, I can
simply use

	$ git checkout HEAD@{1}

3. Now suppose I was not paying attention and made the mistake
from (1) or (2) a week ago and didn't realize it.  Now I want to
get back that code.

If it was situation (1), I can remember the name of the branch
and do

	$ git branch --undelete interesting

No problem [1].  If it was situation (2), I need to dig through the
HEAD reflog.  As Jeff explained, it is possible to script something up
to help organize the search.  I think Casey was suggesting doing that
work at HEAD-reattachment time instead, so you could do

	$ git branch --undelete-detached-head=old-head

to recover the last line of development made without a branch;
my response was that if this ends up frequently being useful
then I suspect something is wrong with the workflow.

Hoping that is clearer,
Jonathan

[1] as long as the branch name was not reused

  reply	other threads:[~2010-12-07 20:55 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-06 21:16 [PATCH] logging branch deletion to help recovering from mistakes Junio C Hamano
2010-12-06 21:55 ` Štěpán Němec
2010-12-06 23:14 ` Andreas Schwab
2010-12-07  1:18 ` Nguyen Thai Ngoc Duy
2010-12-07  6:28   ` Junio C Hamano
2010-12-07 11:37     ` Nguyen Thai Ngoc Duy
2010-12-07 15:25       ` Michael J Gruber
2010-12-07 16:25         ` Nguyen Thai Ngoc Duy
2010-12-07 16:22       ` Jakub Narebski
2010-12-07 16:26         ` Nguyen Thai Ngoc Duy
2010-12-07 17:06     ` Jeff King
2010-12-07 18:14       ` Shawn Pearce
2010-12-07 18:20         ` Jeff King
2010-12-07 18:23           ` Shawn O. Pearce
2010-12-07 18:35             ` Jeff King
2010-12-07 18:37               ` Shawn O. Pearce
2010-12-07 18:39                 ` Jeff King
2010-12-07 18:41                   ` Shawn O. Pearce
2010-12-07 19:21       ` Junio C Hamano
2010-12-07 19:38         ` Jeff King
2010-12-07 16:23 ` Casey Dahlin
2010-12-07 17:45   ` Jonathan Nieder
2010-12-07 17:54     ` Casey Dahlin
2010-12-07 18:02       ` Jonathan Nieder
2010-12-07 18:26         ` Casey Dahlin
2010-12-07 20:25         ` Junio C Hamano
2010-12-07 20:55           ` Jonathan Nieder [this message]
2010-12-07 18:12       ` Jeff King

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=20101207205526.GA25008@burratino \
    --to=jrnieder@gmail.com \
    --cc=cdahlin@redhat.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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;
as well as URLs for NNTP newsgroup(s).