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

Re: Why can't git open empty branches ?

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Apr 11, 2012, 11:21 UTC
Message-ID
<vpq7gxmzf75.fsf@bauges.imag.fr>
In-Reply-To
<4F8565BC.1070701@danisch.de>
Hadmut Danisch <hadmut@danisch.de> writes:
> It is not really plausible to create a new branch by checking out a
> non-existing one.

... but it is hardly useful to create a new branch unless you want to check it out.

I think the most common way to create a branch with Git is "git checkout -b new-branch", which does the creation+checkout in a single command. "git checkout --orphan" is the natural extension of it.

BTW, it is rarely good practice to create an empty branch in an existing repository. You'll have different branches that do not share any history, and they would likely be better in separate repositories (or at least, be in separate local repositories, pushed to the same remote bare repository, in which case you don't need anything special, just "git init" and "git push"). That doesn't mean you shouldn't do it, but just that you may want to think twice before doing it ;-).

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Hadmut DanischNext: Hadmut Danisch
Message 4 of 8 in “Why can't git open empty branches ?”
  1. Hadmut DanischApr 11, 2012
  2. Jonathan NiederApr 11, 2012
  3. Hadmut DanischApr 11, 2012
  4. Matthieu MoyApr 11, 2012
  5. Hadmut DanischApr 11, 2012
  6. Jonathan NiederApr 11, 2012
  7. Matthieu MoyApr 11, 2012
  8. Holger HellmuthApr 11, 2012

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.