Why does git's HEAD file sometimes contain a hash instead of a branch reference?

Viewed 19

When there is a locale git repository there is the file .git/HEAD. It usually (?) contains one line like this

ref: refs/heads/feat/diagnostic

But I sometimes have the situation that this file does contain something like a hash.

fc2301378633136b4d49ff1af27995db6ee5c130

Why is it so?

The background is that this happens on TravisCI. Usually I use the HEAD file and the branch file it points to to determine (without git) the current active branch name and commit hash. But this doesn't work when HEAD contains a hash instead a reference to the branch.

0 Answers
Related