curchod
curchod

Reputation: 291

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).

[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?

Upvotes: 4

Views: 5562

Answers (1)

Ron Harlev
Ron Harlev

Reputation: 16663

This is from two comments above by @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. Your Mac believes that ux and UX are the same file, while your Git believes they are different branches. 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. 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.

Upvotes: 3

Related Questions