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

Re: git merging

From
JAJens Axboe <axboe@suse.de>
Date
Jun 17, 2005, 19:16 UTC
Message-ID
<20050617191627.GZ6957@suse.de>
In-Reply-To
<Pine.LNX.4.58.0506171142500.2268@ppc970.osdl.org>
On Fri, Jun 17 2005, Linus Torvalds wrote:
Show 24 quoted lines
> 
> [ Git mailing list cc'd, since this is a general question that maybe 
>   others have wondered about ]
> 
> On Fri, 17 Jun 2005, Jens Axboe wrote:
> > 
> > btw (and forgive me for just asking you), what is the canonical way to
> > kill a branch in case you want to redo it? right now I have a block tree
> > with a bunch of brances, and I would like to redo one of the branches
> > because I forgot to add the signed-off-by entries in there.
> 
> You can just simply remove the .git/refs/heads/branch-name file (obviously 
> after having made sure that ".git/HEAD" points to something else), and 
> then you can run "git prune", which will remove all objects that aren't 
> referenced (directly or indirectly) by anything in ".git/refs/**".
> 
> Be very very careful, though. "git prune" is a dangerous script, since it
> will remove objects from the object store. If you had something that you
> don't have a proper reference for, or if you give "git prune" a list of
> references manually and it's not complete, "git prune" will happily remove
> objects that you didn't mean for it to remove.
> 
> The "git prune" script is really trivial, you can see for yourself what 
> "git-prune-script" does.
That worked! Thanks.
Show 11 quoted lines
> NOTE! It's entirely possible to not actually delete the old branch, but 
> just rename it, and use it as a reference while you build up the new 
> branch with the same contents (but maybe different commit log messages, or 
> maybe just re-ordering the commits in the new version). To rename a 
> branch, just rename the ".git/refs/heads/<branch-name>" file to something 
> else.
> 
> So you may decide to remove (and prune) the old branch only after you've 
> re-created a new version of it, for example. That way you can use git 
> itself to extract the contents of the branch you want to re-do, which is 
> often easier.

Yeah that's very handy. I love the way the branches work, with just the sha in the file name. So easy to manipulate.

-- 
Jens Axboe
Previous: Linus TorvaldsNext: Jeff Garzik
Message 2 of 16 in “Re: git merging”
  1. Linus TorvaldsJun 17, 2005
  2. Jens AxboeJun 17, 2005
  3. Jeff GarzikJun 17, 2005
  4. Linus TorvaldsJun 17, 2005
  5. Jeff GarzikJun 17, 2005
  6. Linus TorvaldsJun 18, 2005
  7. Jens AxboeJun 20, 2005
  8. Matthias UrlichsJun 20, 2005
  9. Jens AxboeJun 20, 2005
  10. Linus TorvaldsJun 20, 2005
  11. Daniel BarkalowJun 20, 2005
  12. Matthias UrlichsJun 20, 2005
  13. Jens AxboeJun 20, 2005
  14. Linus TorvaldsJun 20, 2005
  15. Jens AxboeJun 21, 2005
  16. Linus TorvaldsJun 21, 2005

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.