开发者

git branch continually getting recreated on pull

I have a git branch that continually gets 'recreated' with an alternating letter case every time I perform a 'git pull'. Assuming the branch name is 'a' (or 'A' for all I know), one 'git pull' will produce the line:

* [new branch]      a       -> origin/a

And then the next 'git pull' will produce:

* [new br开发者_如何学运维anch]      A       -> origin/A

This never stops. I don't know how the branch got created (or what it is for) as someone else created it.

How do I tame this branch and make it stop doing this?


As mentioned in the comments, both refs/heads/A and refs/heads/a exist on the remote. That does mean that two distinct branches exist there. (Git itself is case sensitive, as are most non-Windows filesystems.)

If, however, you're using Windows, that would probably explain this problem. Refs are created as individual files, one per ref. Git sees both on the remote, but then when it attempts to update them locally, only one exists, so the other is always created. The internal order of the two operations must then be such that the newly created one overwrites the other, leading to the alternation.

If the refs are pointing to the same commit, then the solution is to delete one of them on the remote:

git push origin :refs/heads/A


It seems that origin/a and origin/A are deleted locally since you get [new branch] all the time. If someone or something is deleting these references, you will get these branches every time you fetch (or pull) from the remote. Have you tried to re clone the repository? Are you the only one having this problem?


I just encountered this problem. In my case, one of the branch names was in direct descent from the other, so I deleted the older branch from the remote, as it was adding no value. Assume the branch to delete is "a", then this command will remove it from the remote (named "origin"):

git push origin :a

A couple of fetches and the problem is gone (until someone else pushes it again...)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜