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 

$ # 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
$ 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


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