The Question
Question: Why do some local branch names have different cases than the remote branch names (for example "Bugfix/123" vs "origin/bugfix/123" (with small "b")?
The Answer
Answer: Because of a limitation/bug in Git for Windows, branch names sometimes get incorrect casing, but CET Developer handles this by making sure the local branch is always linked to the correct remote branch.
Background
Git stores branch references in local folders under the repo, for example in: .git\refs\remotes\origin.
Each branch has its own file, but when there's a prefix to the name, like "bugfix/" in your case, there will be a subfolder named "bugfix" where the files with the branches are stored.
The problem is that on a windows machine the file system is case-invariant: you cannot have a folder both named "Bugfix" and one named "bugfix". So if for example there's already a folder named "Bugfix", it will use that also for the branch that was actually prefixed "bugfix/", causing git to display the branch as "Bugfix/123" instead of "bugfix/123".
You can easily reproduce the problem by typing the following commands in a command prompt:
>git checkout -b Bugfix/123 Switched to a new branch 'Bugfix/123' >git checkout -b bugfix/124 Switched to a new branch 'bugfix/124' >git branch Bugfix/123 Bugfix/124
As you can see, both branches start with uppercase B even if the second one was created with all lower case letters.
Except for being confusing, it can also create real problems when working against the remote repository, since the GitLab server treats "bugfix/124" and "Bugfix/124" as two different branches, and pushing to the wrong one causes a new branch to be created, instead of pushing the changes to the existing branch.
(Note: To add to the confusion, Git also has a mechanism for packing the ref-files into a single file named "packed-refs", and in that file, the casing always corresponds to the one on the server. So branch names might be displayed differently by git depending on if the branch is packed or unpacked at the moment.)
How It's Handled by CET Developer
To resolve this problem, CET Developer version 10.5.2001.1 and later has a special mechanism for reading remote branch names and does not rely on the output from the "git branch -va"-command since that doesn't always give the correct branch names.
CET Developer will also automatically set the upstream-branch when checking out a branch, so for example if a remote branch named "origin/bugfix/124" is checked out locally and is assigned the incorrect name "Bugfix/124", it will despite that get linked to the correct remote branch when checked out from CET Developer.
But in these cases, the Branch-dialog in CET Developer will show the different casing between the local branch name and the remote branch name.
Comments
0 comments
Please sign in to leave a comment.