All of lore.kernel.org
 help / color / mirror / Atom feed
* git init doesn't create master branch
@ 2013-05-29 12:47 "Ákos, Tajti"
  2013-05-29 12:50 ` Matthieu Moy
  0 siblings, 1 reply; 8+ messages in thread
From: "Ákos, Tajti" @ 2013-05-29 12:47 UTC (permalink / raw)
  To: git

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. How can make sure that master is created?

Thanks in advance,
Ákos Tajti

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: git init doesn't create master branch
  2013-05-29 12:47 git init doesn't create master branch "Ákos, Tajti"
@ 2013-05-29 12:50 ` Matthieu Moy
  2013-05-29 12:54   ` Ramkumar Ramachandra
  0 siblings, 1 reply; 8+ messages in thread
From: Matthieu Moy @ 2013-05-29 12:50 UTC (permalink / raw)
  To: Ákos, Tajti; +Cc: git

"Ákos, Tajti" <akos.tajti@intland.com> 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/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: git init doesn't create master branch
  2013-05-29 12:50 ` Matthieu Moy
@ 2013-05-29 12:54   ` Ramkumar Ramachandra
  2013-05-29 13:01     ` "Ákos, Tajti"
  0 siblings, 1 reply; 8+ messages in thread
From: Ramkumar Ramachandra @ 2013-05-29 12:54 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Ákos, Tajti, git

Matthieu Moy wrote:
>> 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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: git init doesn't create master branch
  2013-05-29 12:54   ` Ramkumar Ramachandra
@ 2013-05-29 13:01     ` "Ákos, Tajti"
  2013-05-29 13:08       ` Matthieu Moy
                         ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: "Ákos, Tajti" @ 2013-05-29 13:01 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: Matthieu Moy, git

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:
>>> 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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: git init doesn't create master branch
  2013-05-29 13:01     ` "Ákos, Tajti"
@ 2013-05-29 13:08       ` Matthieu Moy
  2013-05-29 13:20         ` "Ákos, Tajti"
  2013-05-29 13:20       ` Ramkumar Ramachandra
  2013-05-29 18:37       ` Junio C Hamano
  2 siblings, 1 reply; 8+ messages in thread
From: Matthieu Moy @ 2013-05-29 13:08 UTC (permalink / raw)
  To: Ákos, Tajti; +Cc: Ramkumar Ramachandra, git

"Ákos, Tajti" <akos.tajti@intland.com> writes:

> The command was:
>
> git pull ../dump.dmp refs/heads/*:refs/heads/*

"git pull" does internally a "git fetch" followed by a "git merge".

If you try to pull several branches at the same time, it means you want
to merge all of them together (octopus merge), which probably isn't what
you're trying to do. You probably want just a "git fetch", or specify
only one branch to pull.

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: git init doesn't create master branch
  2013-05-29 13:08       ` Matthieu Moy
@ 2013-05-29 13:20         ` "Ákos, Tajti"
  0 siblings, 0 replies; 8+ messages in thread
From: "Ákos, Tajti" @ 2013-05-29 13:20 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git

Thanks! I ill try using fetch.

Ákos

2013.05.29. 15:08 keltezéssel, Matthieu Moy írta:
> "Ákos, Tajti" <akos.tajti@intland.com> writes:
>
>> The command was:
>>
>> git pull ../dump.dmp refs/heads/*:refs/heads/*
> "git pull" does internally a "git fetch" followed by a "git merge".
>
> If you try to pull several branches at the same time, it means you want
> to merge all of them together (octopus merge), which probably isn't what
> you're trying to do. You probably want just a "git fetch", or specify
> only one branch to pull.
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: git init doesn't create master branch
  2013-05-29 13:01     ` "Ákos, Tajti"
  2013-05-29 13:08       ` Matthieu Moy
@ 2013-05-29 13:20       ` Ramkumar Ramachandra
  2013-05-29 18:37       ` Junio C Hamano
  2 siblings, 0 replies; 8+ messages in thread
From: Ramkumar Ramachandra @ 2013-05-29 13:20 UTC (permalink / raw)
  To: Ákos, Tajti; +Cc: Matthieu Moy, git

"Á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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: git init doesn't create master branch
  2013-05-29 13:01     ` "Ákos, Tajti"
  2013-05-29 13:08       ` Matthieu Moy
  2013-05-29 13:20       ` Ramkumar Ramachandra
@ 2013-05-29 18:37       ` Junio C Hamano
  2 siblings, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2013-05-29 18:37 UTC (permalink / raw)
  To: Ákos, Tajti; +Cc: Ramkumar Ramachandra, Matthieu Moy, git

"Ákos, Tajti" <akos.tajti@intland.com> writes:

> 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?

You are not trying to merge all branches contained in the dump, so
"pull" is a wrong thing to use here.

    $ git fetch --update-head-ok ../dump.dmp refs/heads/*:refs/heads/*

would be one way.  Or you could just use the dumpfile as if it were
a normal remote and say (without running "git init")

    $ git clone dump.dmp undump

to extract it in a new directory "undump" (this may require your
dumpfile created with HEAD, though).

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-05-29 18:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-29 12:47 git init doesn't create master branch "Ákos, Tajti"
2013-05-29 12:50 ` Matthieu Moy
2013-05-29 12:54   ` Ramkumar Ramachandra
2013-05-29 13:01     ` "Ákos, Tajti"
2013-05-29 13:08       ` Matthieu Moy
2013-05-29 13:20         ` "Ákos, Tajti"
2013-05-29 13:20       ` Ramkumar Ramachandra
2013-05-29 18:37       ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.