Cyker
Cyker

Reputation: 10894

Where does Git store remote tracking branches

I have to Git repos repo1 and repo2. There are three branches master, alpha and beta in repo1. repo2 clones from repo1.

In repo2, I can see remote tracking branches with git branch -a:

remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/alpha
remotes/origin/beta

But the folder .git/refs/remotes/origin/ in repo2 only has a single file HEAD, whose content is:

ref: refs/remotes/origin/master

So this HEAD is a symbolic ref. But why does it point to a ref that doesn't exist? BTW, where does repo2 store the information of alpha and beta? (repo2 knows alpha and beta because it displays them in git branch -a.)

Upvotes: 13

Views: 2921

Answers (2)

CB Bailey
CB Bailey

Reputation: 791441

The refs are probably "packed" in .git/packed-refs.

Upvotes: 16

Ben Jackson
Ben Jackson

Reputation: 93690

The information is in .git/config and is updated by tools like git remote when you add or modify remotes. There is a manual page on git-config. If you search for "tracking branches" you'll see details of how they are configured.

Upvotes: 7

Related Questions