Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
625 views
in Technique[技术] by (71.8m points)

case insensitive - Git fetch a branch once with a normal name, and once with capital letter

I'm fetching for remote branches and stuck in some sort of a loop.

I fetch once and get:

$ git fetch
* [new branch]      minorRelease/something-> origin/minorRelease/something

And then I fetch again and get:

$ git fetch
* [new branch]      minorRelease/Something-> origin/minorRelease/Something

Same branch but with a capital S.

I tried to delete the file from the following folder .git/refs/remotes/origin/minorRelease, but when fetching again, I get both and return to the loop above:

$ git fetch
* [new branch]      minorRelease/Something-> origin/minorRelease/Something
* [new branch]      minorRelease/something-> origin/minorRelease/something
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

@torek is right that it's caused by the difference of Linux and Windows. Linux is case-sensitive, while Windows is not. You can use ls-remote to show the branches in the server.

git ls-remote --heads origin

And I think in your case, the output should include the two branches with only the case of S different.

ref/heads/minorRelease/Something
ref/heads/minorRelease/something

You can delete the remote branch if you find one of them is actually duplicated. And then do fetch again. It should be fine now.

git push origin :minorRelease/Something
git fetch

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...