public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Andreas Ericsson <ae@op5•se>
To: Junio C Hamano <junkio@cox•net>
Cc: Bahadir Balban <bahadir.balban@gmail•com>, git@vger•kernel.org
Subject: Re: Cancelling certain commits
Date: Tue, 17 Jan 2006 11:03:52 +0100	[thread overview]
Message-ID: <43CCC108.5000404@op5.se> (raw)
In-Reply-To: <7vvewjlowk.fsf@assigned-by-dhcp.cox.net>

Junio C Hamano wrote:
> Andreas Ericsson <ae@op5•se> writes:
> 
>># make sure "git status" doesn't show any changes
>>
>>$ git branch anchor # to make a safe point to reset to if things go bad
>>$ git reset --hard HEAD~7 # undo commits 3 - 10
>># replay commits 4, 5, 6, 8, 9
>>$ for i in 6 5 4 2 1; do git cherry-pick -r anchor~$i || break; done
>># replay commit 10
>>$ git cherry-pick -r anchor
> 
> 
> I think "6 5 4 2 1 0" would be sweeter.  rev~0 == rev
> 

Didn't know that. The day isn't a complete loss already. :)

> 
>>..., and never *ever*
>>do
>>
>>$ git prune
>>
>>on a repo where you're juggling loose commits like this (although that
>>should actually be safe when you create 'anchor' as a branch rather
>>than as a tag, which Junio usually recommends).
> 
> 
> Sorry, I do not understand this part.  tags and branch heads are
> used in the same way to determine what objects to protect from
> "prune", so I thought there was no difference from the safety
> point of view between the anchor being a branch or a tag.
> 

You're right. That's weird though, because I distinctly remember being 
bitten by this when I was very new to git. OTOH, I probably did 
something stupid that broke the repo before, and my girlfriend provided 
plenty distraction so I didn't do the pruning and the reset'ing on the 
same day.

Would a tag with the same name in a central repo overwrite a local one 
when "git fetch --tags" is used? I think I did this over http, but I'm 
not sure. I know I had to clean up un-annotated tags that got pushed by 
accident after I had restored the lost commits though, so this could be 
a cause (there was an 'anchor' tag in the shared repo as well).

-- 
Andreas Ericsson                   andreas.ericsson@op5•se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

      reply	other threads:[~2006-01-17 10:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-16 13:57 Cancelling certain commits Bahadir Balban
2006-01-16 14:22 ` Andreas Ericsson
2006-01-16 23:43   ` Junio C Hamano
2006-01-17 10:03     ` Andreas Ericsson [this message]

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=43CCC108.5000404@op5.se \
    --to=ae@op5$(echo .)se \
    --cc=bahadir.balban@gmail$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=junkio@cox$(echo .)net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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