On Thursday, June 6, 2013 8:51:50 PM UTC+2, Dale Worley wrote:

> When you want to create a new branch that has no ancestors, you use 
> "git checkout --orphan" to set the repository in a state where the 
> next commit will have no parents.  However, it appears that one can 
> only do "git checkout --orphan" only if the *current* state will *not* 
> create an orphan commit.  This makes no sense, because the current 
> repository state has nothing to do with setting up the next state. 
> Here is a script that shows the problem: 
> $ git --version 
> git version 
> $ # Make a test directory. 
> $ DIR=temp.$$ 
> $ mkdir $DIR 
> $ cd $DIR 
> $ # Create a new repository. 
> $ rm -rf .git 
> $ git init 
> Initialized empty Git repository in 
> /common/home/worley/git-checkout/temp.19517/.git/ 
> $ # Try to create an orphaned branch.  This fails. 
> $ git checkout --orphan first-new-branch 
> fatal: You are on a branch yet to be born 
> $ # Create a commit on branch master.  (We are still on master.) 
> $ git commit --allow-empty -m 'Empty commit.' 
> [master (root-commit) db3f0dd] Empty commit. 
> $ # Try to create an orphaned branch.  This succeeds. 
> $ git checkout --orphan second-new-branch 
> Switched to a new branch 'second-new-branch' 
> $ # Show the Git status. 
> $ git branch 
>   master 
> $ cat .git/HEAD 
> ref: refs/heads/second-new-branch 
> $ # But now we can't create another orphaned branch! 
> $ git checkout --orphan third-new-branch 
> fatal: You are on a branch yet to be born 
> $ 

Repos (or branches) without history are funny places where a lot of 
operations make less or more sense. The place to address this is the Git 
developer mailing list, but the use-case does sound a bit, well, pointless. 
I'm sure it will help if you present them with a valid use-case that this 
is important to fix: https://gist.github.com/tfnico/4441562

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to