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

Re: Checking out orphans with -f

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 18, 2012, 23:12 UTC
Message-ID
<7vk44oli5s.fsf@alter.siamese.dyndns.org>
In-Reply-To
<201201181550.23792.mfick@codeaurora.org>
Martin Fick <mfick@codeaurora.org> writes:
Show 5 quoted lines
> Actually, no I can't.  I can check out some other branch 
> (assuming I have one), but I cannot then delete a, it 
> appears to already be deleted by virtue of checking out 
> another branch.  I like that since I never checked it in, 
> better to clean up the garbage.
Good.
> ...but why can't I then 
> checkout another orphan to do the same thing?

I am not surprised if the original contributor who wanted to add --orphan did not address corner cases. It is very plausible that we did not try as hard to nitpick the code for complete support of such corner cases as I and other contributors usually do for more important features.

So... Patches welcome ;-)

Having said that, there are many things to consider to fill the corner case you seem to be interested to add support for.

The "orphaned" state is like immediately after "git init". Because you do not have any current commit, you cannot create an orphan branch based the state immediately after "git init", either. You are nominally on your 'master' branch, but it does not have anything yet; you are expected to turn it into a real branch by creating a commit soon, but until you do so, you are kind of in-limbo. It is understandable that there will be many operations that will not make any sense until you first get out of this in-limbo state. For example, you cannot (and do not have to) delete the branch and if you have a commit (e.g. you can fetch one from another place) you can check it out and the 'master' will be gone, because you never created it in the first place.

Previous: Martin Fick
Message 5 of 5 in “Checking out orphans with -f”
  1. Martin FickJan 18, 2012
  2. Junio C HamanoJan 18, 2012
  3. Martin FickJan 18, 2012
  4. Martin FickJan 18, 2012
  5. Junio C HamanoJan 18, 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.