简体   繁体   English

Git分支不显示当前分支

[英]Git branch not showing current branch

My co-worker switched to a branch mistakenly using caps for the branch name. 我的同事错误地使用大写字母表示分支名称而切换到分支。 Everything seemed to work fine for him. 一切似乎对他来说都很好。 He made a commit and pushed it. 他做出了承诺并推动了它。
Now however, doing a 'git branch' does not show the previous lower case branch name, and instead the upper case version, but there is no asterix (*) next to the branch name (see the image below). 但是,现在执行“ git branch”不会显示以前的小写分支名称,而是大写版本,但是分支名称旁边没有星号(*)(请参见下图)。

[brettmac15:ehs-hybrid-prototype-2 kulpreetalagh$ git branch
    UX
    development
    master

[brettmac15:ehs-hybrid-prototype-2 kulpreetalagh$ git status
On banch ux
You branch is up-to-date with 'origin/ux'.
nothing to commit, working tree clean

brettmac15:ehs-hybrid-prototype-2 kulpreetalagh$

Is this a bug, did he do something wrong, or is there a way to fix this? 这是错误,还是他做错了什么,还是有办法解决?

This is from two comments above by @torek & @LasseVågsætherKarlsen 这是来自@torek和@LasseVågsætherKarlsen的两条评论

This is one of those case-folded branch name problems, because you are on a Mac using an HFS+ file system that is set to be case-insensitive. 这是那些大小写折叠的分支名称问题之一,因为在Mac上使用的HFS +文件系统设置为不区分大小写。 Your Mac believes that ux and UX are the same file, while your Git believes they are different branches. Mac认为ux和UX是同一文件,而Git则认为它们是不同的分支。 You can fix various names in your repository but you and your co-worker must agree to one particular capitalization and stick with it. 您可以在存储库中固定各种名称,但是您和您的同事必须同意一个特定的大写字母并坚持使用。

Unfortunately git is confused when it comes to case folding like this. 不幸的是,当涉及到这样的情况下折叠时,git感到困惑。 You're best off by checking out the correctly named branch name. 最好签出正确命名的分支名称。 Specifically, git will trust the file system that says "Sure, I found a file inside .git/refs/heads/ux and this is its contents" but then use case sensitive comparison when determining if a branch it is currently listing is the current one. 具体地说,git将信任表示“当然,我在.git / refs / heads / ux中找到了一个文件,这就是它的内容”的文件系统,但是在确定当前当前列出的分支是否为当前文件时使用区分大小写的比较一。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM