git

Where does Git store remote tracking branches


I have two Git repositories 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.)


Solution

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