Home » Git » why does bare repository have HEAD

why does bare repository have HEAD

Posted by: admin November 15, 2021 Leave a comment

Questions:

I’m wondering what’s the purpose of HEAD in bare repository? Is it just used when repository is cloned to know which branch to checkout in cloned repository?

Please note, this question is not about what is HEAD, but given its functions I’m wondering why it’s needed inside bare repository.

Answers:

Can you please name a case where HEAD is used in a bare repository?

See “t/t1430-bad-ref-name.sh

You can do a soft reset in a bare repo, which means you can move HEAD (current commit) around, which is one way to change the default branch.

That means that when you clone a bare repo, the default branch checked out in the non-bare clone will be the one referenced by the bare repo HEAD.