Tuesday, 28 June 2016

Why is git capitalising my branches?

I'm quite new to git and I'mstill getting to grips with git and I've been a little confused that when I create a branch git seems to add uppercase letters, even though I specifically created it in lowercase.

For example:

This responds with:
Switched to a new branch 'grahamr/test'

But when I check the branches it has a different casing:

This caused me some problems when I was trying to push the branch as it that is case sensitive.

Upon doing some digging this is due to the first branch that I created I created began with 'GrahamR'.  The way git creates branches and how they are stored.  Git stores the branch in a single file which contains the hash to the commit object that the branch points to.
In the example above creating a branch 'grahamr/test' will create a folder called 'grahamr' and store the branch in a file called test.
As I originally created a branch that began 'GrahamR' the folder was created and even though the branch was deleted the folder remains.

So to resolve this issue browse to the '.git/refs/heads' folder and then delete the folder (ensure that you have deleted the branches first and the folder is empty):
So now create a new branch:

Then when I check the branch status I see this:

For more info look here:  http://stackoverflow.com/questions/15371866/why-is-git-capitalizing-my-branch-name-prefix