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

Re: Parent-less branches

From
Daniel Barkalow <barkalow@iabervon.org>
Date
May 4, 2008, 05:50 UTC
Message-ID
<alpine.LNX.1.00.0805040139310.19665@iabervon.org>
In-Reply-To
<bd6139dc0805021746q40b384c3nb36a8605d9475a7f@mail.gmail.com>
On Sat, 3 May 2008, Sverre Rabbelier wrote:
Show 17 quoted lines
> On Sat, May 3, 2008 at 2:17 AM, Jakub Narebski <jnareb@gmail.com> wrote:
> >  In short the solution is to create content-less branch using:
> >
> >   $ git symbolic-ref HEAD refs/heads/newbranch
> >   $ rm .git/index
> >
> >  then commit.
> 
> I guess what Pedro is asking is if there isn't a builtin way to do
> this. Which, if I understand correctly, there isn't. Perhaps though
> something like "git branch -N newbranchname" which then creates a new
> parentless branch. It could just be a shell script that does the
> above, but I wonder if there are no side-effects of the above? It
> sounds somewhat 'messy' to remove the index? Too 'low level' to do for
> a user I mean, what if sometime in the future we decide to store
> something in the index that -is- important? I reckon it would be
> cleaner to add an option for this.

If sometime in the future we decide to store something in the index that is important, we'll definitely want to remove the index, because whatever it is will be both important and -wrong- for a new parentless commit, since a new root should have all the default values, not values acquired during the other history in the repo.

On the other hand, a builtin command of that sort probably ought to make sure that there aren't any uncommitted changes before doing this. And it should probably be called "git checkout -b name -N", since it makes it your current branch, rather than creating it like "git branch ..." would suggest.

	-Daniel
*This .sig left intentionally blank*
Previous: Sverre Rabbelier
Message 4 of 4 in “Re: Parent-less branches”
  1. Ulrik SverdrupMay 2, 2008
  2. Jakub NarebskiMay 3, 2008
  3. Sverre RabbelierMay 3, 2008
  4. Daniel BarkalowMay 4, 2008

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.