user1460043
user1460043

Reputation: 2481

Git: branches without a corresponding file in refs/heads

I have a git repository with lots of branches: git branch lists more than 20 branches. But ls .git/refs/heads lists only 4 of them. How can that be?

To investigate the issue a bit, I created a test repository in an empty directory, added one file, commited the change and created a new branch side. Now git branch gives me

* master
  side

and ls .git/refs/heads gives

master  side

However, after a git gc, the files in .git/refs/heads disappear, but git branch still shows me both branches. Where does git get this information from?

Upvotes: 4

Views: 114

Answers (1)

Tom Miller
Tom Miller

Reputation: 820

Your refs are getting packed for performance reasons they can now be found in .git/packed-refs cat .git/packed-refs. This man page does a pretty good job of explaining it https://www.kernel.org/pub/software/scm/git/docs/git-pack-refs.html.

Upvotes: 4

Related Questions