Skip to content

active_branch raises exception when I am on a detached head #510

Closed
@petersohn

Description

@petersohn

If I try to access Repo.active_branch while on a detached head, I get the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/git/repo/base.py", line 670, in active_branch
    return self.head.reference
  File "/usr/local/lib/python2.7/dist-packages/git/refs/symbolic.py", line 258, 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 '955877d6c1720961e13bdf17db7dfa567a11f77b'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions