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:
bugfix
prefix of my branch get capitalized as BUGFIX
?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.
The best practices of the Git branch naming convention 1. Starting branch name with a category word One of the best methods to improve efficiency is by adding a word that categorizes the 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.
To make sure your team is using the agreed conventions, enforce the standards. One of the easiest ways is to use Git hooks, like the pre-commit hook. I hope it will give you an idea about the Git branching models and their naming convention.
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.
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.
Thanks for the answer, it helped me find the solution to my problem, but mine was a little different. In my case, the folder with the capitalized name was not in .git/refs/heads
, but in .git/refs/remotes
.
Some time, long ago, someone had created two remote folders that differed only by the capitalization of the first letter. The capitalized version had been abandoned; but my repo, being from before that time, still had the capitalized spelling.
So every time I tried to pull from the new folder, it would work, but git put the local branch into the capitalized folder locally. The symptom was that I couldn't pull new changes to that branch; I had to delete my local copy and check the remote out again, every time.
My fix was to change the spelling of the folder name in .git/refs/remotes
, and the problem has been resolved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With