From: Andreas Ericsson Date: Tue, 17 Jan 2006 10:03:52 GMT Subject: Re: Cancelling certain commits Message-ID: <43CCC108.5000404@op5.se> In-Reply-To: <7vvewjlowk.fsf@assigned-by-dhcp.cox.net> Junio C Hamano wrote: > Andreas Ericsson 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