* Git branch bug
@ 2007-05-05 16:24 Guido Ostkamp
2007-05-05 16:42 ` Johannes Schindelin
0 siblings, 1 reply; 7+ messages in thread
From: Guido Ostkamp @ 2007-05-05 16:24 UTC (permalink / raw)
To: git
Hello,
I would like to report the following bug:
$ mkdir test
$ cd test
$ git init
Initialized empty Git repository in .git/
$ git branch experimental
fatal: Not a valid object name: 'master'.
So, it seems it is not possible to create a named branch on an empty
repository.
I'm not subscribed to the list, so please keep me directly on CC for any
reply, thanks.
Regards
Guido
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Git branch bug
2007-05-05 16:24 Git branch bug Guido Ostkamp
@ 2007-05-05 16:42 ` Johannes Schindelin
2007-05-05 17:05 ` Daniel Barkalow
2007-05-05 17:44 ` Guido Ostkamp
0 siblings, 2 replies; 7+ messages in thread
From: Johannes Schindelin @ 2007-05-05 16:42 UTC (permalink / raw)
To: Guido Ostkamp; +Cc: git
Hi,
On Sat, 5 May 2007, Guido Ostkamp wrote:
> $ mkdir test
> $ cd test
> $ git init
> Initialized empty Git repository in .git/
> $ git branch experimental
> fatal: Not a valid object name: 'master'.
>
> So, it seems it is not possible to create a named branch on an empty
> repository.
Actually, it is not possible to branch from a non-existing branch. So,
this is somewhat expected from my POV.
Ciao,
Dscho
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Git branch bug
2007-05-05 16:42 ` Johannes Schindelin
@ 2007-05-05 17:05 ` Daniel Barkalow
2007-05-06 6:30 ` Junio C Hamano
2007-05-05 17:44 ` Guido Ostkamp
1 sibling, 1 reply; 7+ messages in thread
From: Daniel Barkalow @ 2007-05-05 17:05 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Guido Ostkamp, git
On Sat, 5 May 2007, Johannes Schindelin wrote:
> Hi,
>
> On Sat, 5 May 2007, Guido Ostkamp wrote:
>
> > $ mkdir test
> > $ cd test
> > $ git init
> > Initialized empty Git repository in .git/
> > $ git branch experimental
> > fatal: Not a valid object name: 'master'.
> >
> > So, it seems it is not possible to create a named branch on an empty
> > repository.
>
> Actually, it is not possible to branch from a non-existing branch. So,
> this is somewhat expected from my POV.
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.
$ git branch experimental
Should probably give a more informative error message, but branches with
no commits that aren't the current branch has no existance at all, so it
can't work to create them without switching to them.
-Daniel
*This .sig left intentionally blank*
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Git branch bug
2007-05-05 16:42 ` Johannes Schindelin
2007-05-05 17:05 ` Daniel Barkalow
@ 2007-05-05 17:44 ` Guido Ostkamp
2007-05-05 17:54 ` Johannes Schindelin
1 sibling, 1 reply; 7+ messages in thread
From: Guido Ostkamp @ 2007-05-05 17:44 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
> On Sat, 5 May 2007, Guido Ostkamp wrote:
>
>> $ mkdir test
>> $ cd test
>> $ git init
>> Initialized empty Git repository in .git/
>> $ git branch experimental
>> fatal: Not a valid object name: 'master'.
>>
>> So, it seems it is not possible to create a named branch on an empty
>> repository.
>
> Actually, it is not possible to branch from a non-existing branch. So,
> this is somewhat expected from my POV.
>From a git beginners point of view, I would expect that the 'master'
branch is automatically created when performing the 'git init'. Why is
this not the case?
Regards
Guido
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Git branch bug
2007-05-05 17:44 ` Guido Ostkamp
@ 2007-05-05 17:54 ` Johannes Schindelin
0 siblings, 0 replies; 7+ messages in thread
From: Johannes Schindelin @ 2007-05-05 17:54 UTC (permalink / raw)
To: Guido Ostkamp; +Cc: git
Hi,
On Sat, 5 May 2007, Guido Ostkamp wrote:
> > On Sat, 5 May 2007, Guido Ostkamp wrote:
> >
> > > $ mkdir test
> > > $ cd test
> > > $ git init
> > > Initialized empty Git repository in .git/
> > > $ git branch experimental
> > > fatal: Not a valid object name: 'master'.
> > >
> > > So, it seems it is not possible to create a named branch on an empty
> > > repository.
> >
> > Actually, it is not possible to branch from a non-existing branch. So,
> > this is somewhat expected from my POV.
>
> From a git beginners point of view, I would expect that the 'master'
> branch is automatically created when performing the 'git init'. Why is
> this not the case?
Well, one side of the branch _is_ created. But you have to provide initial
content, to make it a proper branch, from which you can actually branch
off.
Having said that, and having read Daniels mail, I agree that this
behaviour should be changed, along with the behaviour of "git checkout -b
<branch>" in a fresh repo.
It might be the illogical thing, to allow branching of a
yet-to-be-initialised branch, but it does not hurt either.
Ciao,
Dscho
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Git branch bug
2007-05-05 17:05 ` Daniel Barkalow
@ 2007-05-06 6:30 ` Junio C Hamano
2007-05-06 16:16 ` Daniel Barkalow
0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2007-05-06 6:30 UTC (permalink / raw)
To: Daniel Barkalow; +Cc: Johannes Schindelin, Guido Ostkamp, git
Daniel Barkalow <barkalow@iabervon.org> 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).
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Git branch bug
2007-05-06 6:30 ` Junio C Hamano
@ 2007-05-06 16:16 ` Daniel Barkalow
0 siblings, 0 replies; 7+ messages in thread
From: Daniel Barkalow @ 2007-05-06 16:16 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Johannes Schindelin, Guido Ostkamp, git
On Sat, 5 May 2007, Junio C Hamano wrote:
> Daniel Barkalow <barkalow@iabervon.org> 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.
The point is that you may not want to have a branch named "master", but
rather want your first branch to be named something else. Your project
could be such that "master" would be a confusing term to use for a
default branch. Currently, it's awkward to start a project that avoids
that particular name, which is what it seemed to me that the original
poster was trying to do.
I don't think it's useful to be able to switch to a new yet-to-be-born
branch from any other state, but I do think it's useful to be able to
choose what the first branch is.
-Daniel
*This .sig left intentionally blank*
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-05-06 16:16 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-05 16:24 Git branch bug Guido Ostkamp
2007-05-05 16:42 ` Johannes Schindelin
2007-05-05 17:05 ` Daniel Barkalow
2007-05-06 6:30 ` Junio C Hamano
2007-05-06 16:16 ` Daniel Barkalow
2007-05-05 17:44 ` Guido Ostkamp
2007-05-05 17:54 ` Johannes Schindelin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).