Why does \"git remote show origin\" list remote branches as \"tracked\" even when those branches are not linked to a local branch for pull/push? Does \"tracked\" mean someth
The "tracked" that git remote show
mentions is different from the "tracking" that git branch -vv
talks about, that occurs with git checkout -b <branch> <upstream>
. (Or maybe "different" is too strong a word, since the underlying idea is the same, it's talking about the remote-tracking branches in your repository, rather than whether you have a local branch that happens to have one of those as its upstream.)
In particular, git remote show
examines the fetch =
line(s) for the given remote, and compares this with the references actually available now on the remote (run git ls-remote
to see those).
The default fetch =
line for the remote named origin
reads:
fetch = +refs/heads/*:refs/remotes/origin/*
Note the two *
s. The one on the left matches all branches that exist on the remote, while the one on the right means "replace with the same name matched on the left".
Suppose that remote origin
currently has the following refs:
refs/heads/master
refs/heads/newbr
refs/tags/v1.2
refs/notes/commits
Suppose further that branch newbr
is new since the last time you cloned, fetched, or otherwise talked to remote origin
, so that git branch -r
will only list origin/master
, not origin/newbr
.
If you now run git remote show origin
you will get (along with the other stuff) this bit:
master tracked
newbr new (next fetch will store in remotes/origin)
This means that both branches match, and you already have refs/remotes/origin/master
, but you do not yet have refs/remotes/origin/newbr
.
Once you run git fetch
, you will acquire origin/newbr
. But if, before you do run git fetch
, you change your fetch =
line so that you won't acquire origin/newbr
, git remote show origin
will stop mentioning it.