default HEAD in git when multiple branch HEADs refer to the same SHA1
in my project, I usually have a (development) branch leading to the next release version at which point the development branch will be merged into the release branch, and then a new development branch will be created.
This means, two branch HEADs will be pointing to the same commit:
$> cd project.git
$> rgrep release .
./packed-refs:2808f1de3e05bf7fcc509c20f31a93e2ba645bd3 refs/heads/release
$> rgrep 2808f1de3e05bf7fcc509c20f31a93e2ba645bd3 .
./packed-refs:2808f1de3e05bf7fcc509c20f31a93e2ba645bd3 refs/heads/release
./packed-refs:2808f1de3e05bf7fcc509c20f31a93e2ba645bd3 refs/heads/development_0103
I want people who clone from my repo to automatically get a check out of the release branch.
$> cd project.git
$> git symbolic-ref HEAD
refs/heads/release
but, when cloning from that r开发者_高级运维epo apparently people get the alphabetically first matching branch checked out
$> git clone project.git/ project.clone
$> cd project.clone
$> git status
# On branch development_0103
nothing to commit (working directory clean)
It seems to me git is working out the branch name to check out by looking at the SHA1, but not actually using the remote's symbolic-head HEAD.
Is there any way to solve this and make the clone default to 'release' instead of 'development_0103'?
You can use separate remote repository for pushing public releases instead of using your way.
You will work as usual in your dev remote repo. merge stable commit to the release branch. and after that git push release_origin release
. So you could share only this release_origin repo with another people.
Or there is another hack for that. :) Just rename your release branch to a_release, so it will be first alphabetically. :)
精彩评论