Now, I don't know if a ref is considered to be a branch only if it's inside refs/heads, and indeed the question was previously titled How to checkout a branch stored outside refs/heads?. So I'm not sure if refs stored outside refs/heads can still be called "proper branches" or not, but the point is:
Let's say I have a ref to a commit as all normal branches are, but stored outside refs/heads; for example, the notes added with git-notes are stored this way, by default in the ref refs/notes/commits.
Can it still, in some way, be checked-out as if it were a normal branch (not doing a detached-head checkout), and thereafter be worked-on with the other git commands (rebase, cherry-pick etc.), as if it were a normal refs/heads branch?
I know that a normal git checkout
will only check it out as a commit, placing the repository in detached-head state.
I did find out a way that seems to work, that is:
git symbolic-ref HEAD refs/MyUnusualRefPath/MyUnusualRef
git checkout -f HEAD
And I was able to do what this time I had to do, apparently, but I wanted to know if in general this is a supported, or sort-of-supported, or at least "right now it works well", operation, and if I can rely on it in the future and suggest others to utilize it.
I tried to look at the source for git checkout, but after a while it was clear that I'd better post a question in Stack Overflow (I searched on the web before, of course).
On hindsight it might have taken less to study the (whole) git source code.
I needed this thing indeed to solve problems with the sharing of (the horribly implemented / documented) notes between repositories, but please don't focus on this and just answer my above question, or else just ignore it and let others who are knowledgeable about it answer.