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

Re: PEBKAC or bug: unable to create path-like branch names

From
Jacob Helwig <jacob.helwig@gmail.com>
Date
Nov 15, 2009, 07:55 UTC
Message-ID
<8c9a060911142355i1e722f50uf21446524fe9cb9c@mail.gmail.com>
In-Reply-To
<20091115073628.GE5934@penguin.codegnome.org>
On Sat, Nov 14, 2009 at 23:36, Todd A. Jacobs <nospam@codegnome.org> wrote:
Show 27 quoted lines
> On Sat, Nov 14, 2009 at 09:36:47PM -0800, Jacob Helwig wrote:
>
>> What version of git are you using?  git checkout -b foo/bar/baz works
>
> I'm using 1.6.5.2 as well. Okay, try this in a temp directory, and
> you'll see what I mean:
>
>    git init
>    echo foo > foo
>    git add foo
>    git commit -m testing foo
>    git checkout -b dev
>    git checkout -b dev/feature/foobar
>
> The first branch works fine, but after attempting the nested branch the
> message reappears:
>
>    error: unable to resolve reference refs/heads/dev/feature/foobar: Not a directory
>    fatal: Failed to lock ref for update: Not a directory
>
> I can recreate this behavior at any time; it isn't just a problem with
> an existing repository.
>
> --
> "Oh, look: rocks!"
>        -- Doctor Who, "Destiny of the Daleks"
>

The problem is that you have a branch dev. You can't have both a file, and a directory with the same name.

You're trying to get git to do basically this:

% cd .git/refs/heads % ls -l total 0 -rw-rw-r-- 1 jhe jhe 41 2009-11-14 23:51 dev -rw-rw-r-- 1 jhe jhe 41 2009-11-14 23:51 master % mkdir dev mkdir: cannot create directory `dev': File exists

You're getting the equivalent of the "cannot create directory" error. When you have a branch with slashes in it, it gets stored as a directory hierarchy under .git/refs/heads.

-Jacob
Previous: Todd A. JacobsNext: Daniel Barkalow
Message 5 of 7 in “Preserving empty directories when doing a git-svn clone/rebase”
  1. Steven J. MurdochNov 15, 2009
  2. PEBKAC or bug: unable to create path-like branch namesTodd A. Jacobs, Nov 15, 2009
  3. Jacob HelwigNov 15, 2009
  4. Todd A. JacobsNov 15, 2009
  5. Jacob HelwigNov 15, 2009
  6. Daniel BarkalowNov 15, 2009
  7. Eric WongNov 16, 2009

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.