Michael Soulier
Michael Soulier

Reputation: 821

Git repository is on the master branch, but has no master ref

I just came across this in one of my git repos due to a failure in a script of mine. I thought that every branch head, including master, had a corresponding ref. That's true in most of my repos, but I have two of them that don't.

git branch says * master and two tracking branches

but .git/refs/heads is empty

So I obviously misunderstand what the heads refs are for. My config has master in it

[branch "master"]
    remote = origin
    merge = refs/heads/master

but that refs/heads/master isn't there.

Any idea what's going on?

Upvotes: 0

Views: 386

Answers (1)

zigarn
zigarn

Reputation: 11595

For optimization reasons, sometimes git packs the references in .git/packed-refs in the format:

e220b43404aca15574c7a9be3724a40587093414 refs/heads/master

Once you change the value for the reference, it will create back a .git/refs/heads/master file (until the next packing).

Upvotes: 1

Related Questions