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 repo 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'?
The term HEAD refers to the current commit you are viewing. By default, you'll view the tip of the master branch on a repository, unless the main branch of your repository has a different name. The tip of the master branch is the most recent commit on the main branch of your codebase.
When working with Git, only one branch can be checked out at a time - and this is what's called the "HEAD" branch. Often, this is also referred to as the "active" or "current" branch. Git makes note of this current branch in a file located inside the Git repository, in .
Yes, two branches can point to the same commits.
ref~2 means the commit's first parent's first parent. ref~3 means the commit's first parent's first parent's first parent. And so on. ref^ is shorthand for ref^1 and means the commit's first parent.
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. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With