J. Schei J. Schei - 3 months ago 12
Git Question

Git not showing star next to current local branch

I am new to git and have encountered a confusing situation.

In summary I am having trouble understanding how case-sensitivity works pertaining to branch names. For example I am on the master branch and create a new branch called AP-1025 with the command

git checkout -b AP-1025
, now I can do a
git branch
and I see that I am on AP-1025 as it has a star next to it.

Now lets say I make some changes on AP-1025, commit them, and switch back to master with
git checkout master
. I am back on the master and everything is fine, however if I now do a
git checkout ap-1025
(notice the lower case characters, and no -b, meaning a new branch was not created). It tells me I have switched to ap-1025, but this time when I perform a
git branch
, AP-1025 does not have a star next to it, and there is no branch appearing with a star next to it.

My confusion arises from the fact that git allows me to perform the
git checkout ap-1025
without complaining about a missing branch, so I assume the branch names are not case sensitive. However
git branch
does not indicate I am truly on the AP-1025 branch, which indicates that some part of the branch naming/commands is case sensitive.

Am I truly on the AP-1025 at that time? How come
git branch
does not show any branch with a star next to it? Is this a bug in the
git branch
command?

Any pointers are greatly appreciated.

kan kan
Answer

I guess you use Windows. Git stores branches as files on disk. Also branch name is stored in the HEAD reference as a name. On Windows if you create file AP-1025 you could open it later as ap-1025 which causes misbehaviour in git as names actually differ, but Windows allow to open the file to read branch info.

Comments