git: difference between “branchname” and “refs/heads/branchname”

Question:

Best to be explained at an example: I am on branch 0.58 of repository and this his how I pull:

When I just call “git pull”, I get:

Seems I probably forgot some option (–track ?) when I checked that branch out. Anyway, I have set this now:

And this seems to work. Then, just because of interest, I took a look at some other branch about these setting:

I was wondering now, is there a difference between “0.58” or should I specify “refs/heads/0.58”?

What is the difference exactly?

Answer:

A ref is anything pointing to a commit, for example, branches (heads), tags, and remote branches. You should see heads, remotes, and tags in your .git/refs directory, assuming you have all three types of refs in your repository.

refs/heads/0.58 specifies a branch named 0.58. If you don’t specify what namespace the ref is in, git will look in the default ones. This makes using only 0.58 conceivably ambiguous – you could have both a branch and a tag named 0.58.

Leave a Reply