Re: git init doesn't create master branch

4 messages, 3 authors, 2016-06-15 · open the first message on its own page

Re: git init doesn't create master branch

From: Matthieu Moy <hidden>
Date: 2016-06-15 22:57:29

"Ákos, Tajti" [off-list ref] writes:
Dear List,

the manual of git init says: "An initial HEAD file that references the
HEAD of the master branch is also created."

However, after creating the repository using git init there's no
master branch.
Right, but HEAD still points to it ;-). We sometimes call this an
"unborn branch".
How can make sure that master is created?
It will be created when you do the first commit. If you insist in having
master created before you actually start working, you can run:

  git commit -m "Initial empty commit" --allow-empty

Right after "git init".

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

Re: git init doesn't create master branch

From: Ramkumar Ramachandra <hidden>
Date: 2016-06-15 22:57:29

Matthieu Moy wrote:
quoted
the manual of git init says: "An initial HEAD file that references the
HEAD of the master branch is also created."

However, after creating the repository using git init there's no
master branch.
Right, but HEAD still points to it ;-). We sometimes call this an
"unborn branch".
Right.  Let me also add that our prompt has support for this; on an
unborn branch, my prompt looks like:

artagnon|master#:/tmp/foo$
               ^
	       the # indicates unborn branch

Please consider using contrib/completion/git-prompt.sh to make your life easier.

Re: git init doesn't create master branch

From: Ákos, Tajti <hidden>
Date: 2016-06-15 22:57:29

Thanks for clarifying this thing for me! I don't really insist on having 
a master branch it's just that I tried to pull from a repository bundle 
and I got this error message:

"Cannot merge multiple branches into empty head"

The command was:

git pull ../dump.dmp refs/heads/*:refs/heads/*

Is this a better way of doing this?

Thanks,
Ákos

2013.05.29. 14:54 keltezéssel, Ramkumar Ramachandra írta:
Matthieu Moy wrote:
quoted
quoted
the manual of git init says: "An initial HEAD file that references the
HEAD of the master branch is also created."

However, after creating the repository using git init there's no
master branch.
Right, but HEAD still points to it ;-). We sometimes call this an
"unborn branch".
Right.  Let me also add that our prompt has support for this; on an
unborn branch, my prompt looks like:

artagnon|master#:/tmp/foo$
                ^
	       the # indicates unborn branch

Please consider using contrib/completion/git-prompt.sh to make your life easier.

Re: git init doesn't create master branch

From: Ramkumar Ramachandra <hidden>
Date: 2016-06-15 22:57:29

"Ákos, Tajti" wrote:
"Cannot merge multiple branches into empty head"

The command was:

git pull ../dump.dmp refs/heads/*:refs/heads/*

Is this a better way of doing this?
pull runs a fetch, which updated .git/FETCH_HEAD.  Now, if
.git/FETCH_HEAD has just one branch (and other not-for-merge entries),
there's no problem.  We just run update-ref HEAD, and get it to point
to the sole branch that was fetched.  If your fetch fetches multiple
branches, and you have a real branch (not "unborn") with
branch.<name>.merge set, we know which one of those branches to merge
in.

Now, what you have is a fetch which fetches multiple branches, and
you're trying to merge that into a non-existent HEAD (or unborn
branch).  There is ambiguity and arguably no "right" thing to do,
which is why git complains.  I'm not sure if it's possible to argue
differently and patch git-pull.sh for your usecase.

There are many possible solutions to the problem, depending on what
you want.  The simplest I can suggest is: ignore the error for that
command and run git reset --hard.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help