git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git init doesn't create master branch

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
May 29, 2013, 13:20 UTC
Message-ID
<CALkWK0nLJn2EDy9KO+Qp3sHhxgyKQag-575srq5ztuu5LgsmyA@mail.gmail.com>
In-Reply-To
<51A5FC17.8000608@intland.com>
"Ákos, Tajti" wrote:
Show 7 quoted lines
> "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.

Previous: Ákos, TajtiNext: Junio C Hamano
Message 7 of 8 in “git init doesn't create master branch”
  1. Ákos, TajtiMay 29, 2013
  2. Matthieu MoyMay 29, 2013
  3. Ramkumar RamachandraMay 29, 2013
  4. Ákos, TajtiMay 29, 2013
  5. Matthieu MoyMay 29, 2013
  6. Ákos, TajtiMay 29, 2013
  7. Ramkumar RamachandraMay 29, 2013
  8. Junio C HamanoMay 29, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.