git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Cancelling certain commits

From
Andreas Ericsson <ae@op5.se>
Date
Jan 17, 2006, 10:03 UTC
Message-ID
<43CCC108.5000404@op5.se>
In-Reply-To
<7vvewjlowk.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano wrote:
Show 14 quoted lines
> 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. :)
Show 16 quoted lines
> 
>>..., 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
Previous: Junio C Hamano
Message 4 of 4 in “Cancelling certain commits”
  1. Bahadir BalbanJan 16, 2006
  2. Andreas EricssonJan 16, 2006
  3. Junio C HamanoJan 16, 2006
  4. Andreas EricssonJan 17, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.