15
origin/joetest
origin/JoeTest

I have a problem I have two remote branches in git which are the same name with different case.

I can't work out what todo in visual studio online I can see the differences but it can't merge them because of conflicts.

The git tools in visual studio and git bash can't tell the difference between the two cases and the people working on them the syncing is now off with some commits on one and some on the other.

any thoughts on what the heck we can do?

thanks

Etan Reisner
  • 77,877
  • 8
  • 106
  • 148
Kisbys
  • 413
  • 1
  • 3
  • 12

3 Answers3

14

Clone the repository on an operating system with a case-sensitive file system, e.g. Linux, then rename one of the branches, push it, and delete the old branch:

git clone <url> repo
cd repo
git checkout -b joetest2 origin/JoeTest
git push origin joetest2:joetest2
git push origin :JoeTest

As for why Git is having issues with branch names with different case, see this related question.

Community
  • 1
  • 1
poke
  • 369,085
  • 72
  • 557
  • 602
  • 1
    Thanks any chance if I don't have access to a case-sensitive file system... we all use windows here... – Kisbys Aug 04 '15 at 16:43
  • You could boot a small Linux in a VM to solve this; but let me try to replicate the problem, and I’ll see if you can solve it from within Windows alone. – poke Aug 04 '15 at 16:46
  • tell you what I'll download umbuto don't want you slaving away for me!! – Kisbys Aug 04 '15 at 16:49
  • Haha, alright ;) Although… I did try it on Windows now. If you start with a fresh clone, above commands should work just the same; at least it worked just now for me :) – poke Aug 04 '15 at 16:54
  • You don't need a linux VM or any stuff. Just use git mv. See http://stackoverflow.com/a/37744442/158285 – bradgonesurfing Jun 10 '16 at 09:17
  • 1
    To delete the old branch without having to create new clone or use a case-sensitive file system, you can also navigate into the `.git\refs\remotes\origin` directory and temporarily change the folder name casing to match the `joetest` or `JoeTest` variation that you want to delete. – veertien Dec 28 '16 at 13:01
0

Just describing a method to do this if it involves GitLab.

We had 2 similarly named branches: (1) develop - the official branch (2) Develop - the bad branch differing only in casing.

It was not possible to pull down the bad "Develop" branch into SourceTree since both branches were similarly named.

This was how this was fixed:

  1. We needed to rename the bad branch "Develop" but GitLab doesn’t provide a mechanism for this. So, in the GitLab portal, we branched a new branch (calling it Develop_Bad) from the old branch. (a) Go to the GitLab portal of Gitlab//Repository/Files. Select the bad branch Develop, eg: https://gitlab.com/mobilityone/GEMS/-/tree/Develop (b) Under the [Develop] GEMS/[+] dropdown, select New Branch (c) Name the new Branch Develop_Bad Pull Develop_Bad into SourceTree on your local machine.

  2. Merge the Develop_Bad into your official develop branch, resolving any merge conflicts. Push the changes to remote.

  3. Delete bad branches "Develop", "Develop_Bad" in the GitLab portal (a) Go to GitLab portal of Gitlab//Repository/Branches https://gitlab.com/mobilityone/GEMS/-/branches (b) Under Active branches section, look for the bad branch Develop (c) Beside this entry, there is a Delete branch icon (garbage bin icon). Click on this to delete the branch after ensuring you won’t lose any data. (d) Do the same with Develop_Bad.

Y-Mi Wong
  • 86
  • 1
  • 5
-1

There is some magic I just discovered and it works under windows. I had two directories

XUnitRemote and XunitRemote

I did the following

 git mv XunitRemote XUnitRemote.todo
 git mv XUnitRemote.todo XUnitRemote

and it just worked

bradgonesurfing
  • 30,949
  • 17
  • 114
  • 217