Re: Git branch bug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Daniel Barkalow <barkalow@xxxxxxxxxxxx> writes:

> This leaves open the question of how you make your initial commit in a 
> branch that isn't master. I think the answer should be:
>
>  $ git checkout -b experimental
>  warning: You appear to be on a branch yet to be born.
>  warning: Forcing checkout of HEAD.
>  fatal: just how do you expect me to merge 0 trees?
>
> Which should probably be:
>
>  $ git checkout -b experimental
>  warning: You appear to be on a branch yet to be born.
>  warning: Putting you on a new branch yet to be born.
>
> And leaving .git/HEAD pointing to refs/heads/experimental instead of 
> refs/heads/master, with refs/heads/ still empty.

While I agree that is probably correct, it would not be useful
in real-life that much.  When you do not even have 'master', I
do not think there is much point of being able to create two
useless, yet-to-be-born branches.

Also, once you make a commit on 'master', you would not be able
to create a new disconnected root with your suggestion alone.  I
am not convinced that being able to start a disconnected root is
useful to begin with, but it is a different matter.  We allow
fetching and merging from a different repository to cause
disconnected roots to exist in a repository anyway, so I do not
see any reason to disallow it either.

Assuming that the ability to switch to a new yet-to-be-born
branch is useful, I think the right thing to do is:

 - Regardless of your HEAD state, you may want to have a way to
   create a yet-to-be-born branch and switch to it.  Perhaps
   "git checkout -e new" make HEAD point at refs/heads/new
   without creating one (I picked -e randomly for "empty").

 - When you are on a yet-to-be-born branch, "git checkout -b
   new" and "git checkout -b new HEAD" makes HEAD point at
   refs/heads/new without creating one.  I happen to consider
   this a not so useful corner case, but that is to make things
   consistent.

 - When you are on a yet-to-be-born branch, "git branch new" and
   "git branch new HEAD" is a nonsense operation.  We should
   clearly state that it is nonsense (I am agreeing with the
   last point in your message).

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]