在Git分支名称中使用斜线字符 [英] Using the slash character in Git branch name
问题描述
然而,当我尝试创建一个名为feature / xyz的模式时,分支与斜线字符,我得到一个错误:
$ git分支实验室/功能
错误:无法解析引用refs / heads / labs / feature:不是目录
fatal:无法锁定ref for update:不是目录
同样的问题(我最初的尝试):
$ git checkout -b labs / feature
如何使用斜线字符在Git中创建分支?
您不能同时拥有文件和名称相同的目录。 您正试图基本上这样做:
%cd .git / refs / heads
%ls -l
总数0
-rw-rw-r-- 1 jhe jhe 41 2009-11-14 23:51实验室
-rw-rw-r-- 1 jhe jhe 41 2009-11-14 23 :51 master
%mkdir labs
mkdir:无法创建目录'labs':文件存在
您将得到与无法创建目录相同的错误。
当您在其中有一个斜杠的分支时,它将被存储为
目录层次结构,位于.git / refs / heads
。
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 character, I get an error:
$ git branch labs/feature
error: unable to resolve reference refs/heads/labs/feature: Not a directory
fatal: Failed to lock ref for update: Not a directory
Same problem for (my initial attempt):
$ git checkout -b labs/feature
How does one create a branch in Git with the slash character?
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
.
这篇关于在Git分支名称中使用斜线字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!