Git tracking issue – case sensitivity matters

0
66

A short reminder to future me. A few days ago I found that even if I switch to someone else’s remote branch, I can’t see my commits pushed to it. More accurately speaking: the PullRequest page (I use Azure DevOps) doesn’t list them. After a not very long time, I realised that the issue is caused by naming convention.

In the previous article, I mentioned that Git is very flexible in naming branches. And I usually use this flexibility. My standard branch name is:

users/pasz/TicketNumber_Description/BugNumber_Version 

But usually, I work on my branches only. However, recently I started to cooperate a lot with different team members. We created a branching name strategy that everyone should follow. Then we started our work on different branches and from time to time I have to switch between to change some things on one, others on another branch. A lot of switching 🙂

Problem

Much to my surprise, at some point I observed that my recent change in my colleague’s branch is not visible in the Azure DevOps’ PullRequest card.

After investigation I found that the problematic branch is named:

Off/RJ/TicketNumber_Description

But SmartGit that I use checked out this branch as

off/RJ/TicketNumber_Description

So I have the situation when DevOps see the branch with correct letter sizes and my Git client doesn’t. When I push commits, I push them not to the desired remote branch, but rather to the newly created remote branch. Azure DevOps shows that clearly:

But my SmartGit tool doesn’t:

Sorry for erased details, my superiors told me to do so :P. Anyway, it’s all about first letter of the branch name, nothing else matters.

So we know the problem exists. I think it’s because Git is case sensitive, and SmartGit (SourceTree most probably too) is not. The problem with SmartGit is that the Set Tracked Branch popup doesn’t allow to write the branch name. Instead, it offers a drop-down list with incorrectly named branches. So I think there is no way to deal with this issue, at least in version 19.1.8.

Fix

What to do then? The answer is simple. Copy correct name from DevOps, open Git Shell and write:

git checkout Off/RJ/TicketNumber_Description

Which will checkout the correct branch + start tracking the one from remote. The workaround, but very simple. Hopefully, this incorrect behaviour of the SmartGit will be fixed in the future versions (or maybe it’s already fixed?). Anyway if you spot a similar situation, where your commits seem to vanish, check whether the spelling/size of the letters is OK. If not, use the shell to check out the correct branch.


Warning: A non-numeric value encountered in /home/platne/serwer17076/public_html/wp-content/themes/Newspaper/includes/wp_booster/td_block.php on line 1008