what determines default branch when cloning from git bare repository

大憨熊 提交于 2019-12-08 07:18:59

问题


I'm trying to change the default branch when cloning from a git bare repo using git 1.8.3.1 from yum install. I had always assumed that the way to do this would be to change the reference inside the HEAD file of the remote repo, and several SO answers seem to confirm this.

However, I'm finding the value of HEAD in the remote bare repo to have no effect. Even though my remote repo has this value in HEAD:

ref: refs/heads/secondbranch

I'm still defaulted to firstbranch branch when I clone! Any ideas what's going on here? Where else might this info be stored?


回答1:


Old versions of git do not send the "default branch" when fetching and cloning. Instead, they send the object ID of the current HEAD reference, as well as the object ID of the other references. If the object ID of HEAD is the same as the object ID of another reference, it will set HEAD to point to that reference. (If there was no match, you will be in a detached HEAD state.)

The disambiguation logic is fuzzy, though, if you have more than one branch pointing to the same commit. It will prefer a branch named master, then it will simply pick the one it saw first.

Stop laughing, I'm serious.

This was fixed in Git 1.8.4.3.



来源:https://stackoverflow.com/questions/26896894/what-determines-default-branch-when-cloning-from-git-bare-repository

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!