为什么git大写我的分支名称前缀? [英] Why is git capitalizing my branch name prefix?
问题描述
我有一组非常简单的git命令,导致了一些奇怪的行为:
显示我当前的本地分支,看到我在 release / beta1
:
$ git分支
开发
master
release / beta1
创建一个 bugfix / somefeature 从
release / beta1
的分支:
$ git checkout -b bugfix / somefeature
转换到一个新分支'bugfix / somefeature'
到目前为止很好,对吧?那么再次向我展示本地分支:
$ git branch
修正/ somefeature
$ c
为什么 bugfix
我的分支的前缀大写为 BUGFIX
?
没有标记星号作为我当前的分支?
我在OS X 10.8上通过Homebrew使用git 1.8.1.5版本。 2,而且这种情况发生在我的漂亮的〜/ .gitconfig
中。这种情况发生在每个 bugfix /...$c $ c>分支上。 解决方案
分支作为文件存储在 .git
目录中。一个分支是一个单独的文件,其中包含分支指向的提交对象的散列。
因此, > foo / bar 这将对应一个带有文件的目录。所以Git会用文件 bar
创建一个文件夹 foo
,然后指向提交。
这意味着当你添加另一个分支 foo / baz
时,它会创建一个文件 baz
并将其添加到文件夹中。
现在分支名称对于不区分大小写的文件系统是不区分大小写的。这意味着 FOO / bar
和 foo / bar
是一样的。但实际的内部名称取自原始文件夹和文件名。因此,当您的 bugfix
分支类别的文件夹以大写字母写入时,则会以大写 BUGFIX
。
要解决这个问题,只需进入 .git / refs / heads
并将文件夹名称更改为你喜欢的方式。
I have a really straightforward set of git commands that is resulting in some curious behavior:
Show my current local branches, and see that I'm on release/beta1
:
$ git branch
develop
master
* release/beta1
Create a bugfix/somefeature
branch from release/beta1
:
$ git checkout -b bugfix/somefeature
Switched to a new branch 'bugfix/somefeature'
So far so good, right? Well, show me local branches again:
$ git branch
BUGFIX/somefeature
The questions:
- Why did the
bugfix
prefix of my branch get capitalized asBUGFIX
? - Related, why is that not marked with an asterisk as my current branch?
I'm using git version 1.8.1.5 via Homebrew on OS X 10.8.2, and this happens with or without my pretty tame ~/.gitconfig
in place. This happens for seemingly every bugfix/...
branch.
Branches are stored as files within the .git
directory. A single branch is a single file containing the hash to the commit object the branch points to.
So, as you maybe guess, when creating a branch foo/bar
this will correspond to a directory with a file. So Git will create a folder foo
with a file bar
which then points to the commit.
This means when you add another branch foo/baz
it will create a file baz
and add that to the folder.
Now branch names are case insensitive for case insensitive file systems. This means that FOO/bar
and foo/bar
are the same. But the actual internal name is taken from the original folder and file name. So when the folder for your bugfix
branch category is written in upper case, then the branches are recognized with an upper case BUGFIX
.
To fix this, just go into .git/refs/heads
and change the folder name to the way you like.
这篇关于为什么git大写我的分支名称前缀?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!