Home > Back-end >  git internals: where is upstream tracking branch stored?
git internals: where is upstream tracking branch stored?

Time:04-30

I know that I can see which upstream branch is being tracked by a local branch by running git branch double verbose:

dino@DINO:$ git branch -vv
  master         b567464 [origin/master] mav cross point example
  p516p          198bf21 [joesmith/master] start adding docs
  p516test       198bf21 start adding docs
* pull_507       4ceafac [soandso/master] restore blah blah blah.
  zorder         13f8d22 [origin/zorder] initial `zorder` tests

The remote tracking branch (if there is one) is shown in square brackets.

My question is: where is this information, this association between the local branch and the remote branch, stored?

I've poked around under .git/refs/ and .git/remotes/, but I am unable to find anything, for example, that lists the association between branch p516p with remote joesmith/master.

(Notice that branch p516test points to the same reference as p516p, but p516test is not tracking any remote. I set it up that way on purpose, in hopes of finding where the tracking remote is stored, by comparing information for p516p with that for p516test; no luck so far).

CodePudding user response:

It's in .git/config. For example:

[branch "main"]
    remote = origin
    merge = refs/heads/main
  • Related