Normally when you run something like this inside of a git repository:
git checkout abc1234
You end up in a detached HEAD state. If you run git branch
, the output will look something like this:
* (detached from abc1234)
master
This is fine and expected behaviour.
I've been playing around with pygit2 recently, and have come across something I haven't seen before. Let's say I do the following:
repo = pygit2.discover_repository("/path/to/repo")
repo.head = "abc1234"
I would expect the repository to be in a detached HEAD state. For all intents and purposes, I believe it is after doing this. However, the output from git branch
looks a bit different:
* (no branch)
master
Does anyone know what the difference is, why there is a difference, and what it means?
EDIT:
Below is the reflog after cloning a repository using pygit2, assigning a commit SHA1 hash to repo.head, then running git checkout master
, then running git checkout myhash
:
69df316 HEAD@{0}: checkout: moving from master to 69df3161f315e9b13ba4bd811635c11f67616598
d6ece61 HEAD@{1}: checkout: moving from 69df3161f315e9b13ba4bd811635c11f67616598 to master
69df316 HEAD@{2}:
d6ece61 HEAD@{3}: clone: from file:///path/to/repo