Using the slash character in Git branch name

后端 未结 6 1027
孤城傲影
孤城傲影 2020-11-22 11:28

I\'m pretty sure I saw somewhere in a popular Git project the branches had a pattern like \"feature/xyz\".

However when I try to create a branch with the slash chara

6条回答
  •  春和景丽
    2020-11-22 11:49

    Are you sure branch labs does not already exist (as in this thread)?

    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 labs
    -rw-rw-r-- 1 jhe jhe 41 2009-11-14 23:51 master
    % mkdir labs
    mkdir: cannot create directory 'labs': 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.

提交回复
热议问题