Closed as not planned
Description
Setup
Running on GitPython==3.1.27
MacOS monterey
, Python 3.10.5
Reproduce the bug
git checkout <commit>
-> leads to a detached HEAD
from pathlib import Path
from git import Repo
def repo() -> 'Repo':
from git import Repo # type: ignore
return Repo(Path(__file__).parent, search_parent_directories=True)
repository = repo()
repository.active_branch.name
Error log
❯ python3 test.py
Traceback (most recent call last):
File "/test.py", line 9, in <module>
repository.active_branch.name
File "/venv/lib/python3.10/site-packages/git/repo/base.py", line 797, in active_branch
return self.head.reference
File "/venv/lib/python3.10/site-packages/git/refs/symbolic.py", line 294, in _get_reference
raise TypeError("%s is a detached symbolic reference as it points to %r" % (self, sha))
TypeError: HEAD is a detached symbolic reference as it points to '7sfaslkhfuhajkfnjaksdhfc4ede32c'
visual proof
Metadata
Metadata
Assignees
Labels
No labels