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
  • 73,512
  • 8
  • 94
  • 138
Kisbys
  • 373
  • 2
  • 12

2 Answers2

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
  • 339,995
  • 66
  • 523
  • 574
  • 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
-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
  • 29,669
  • 13
  • 106
  • 205