Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Exception on repo().active_branch.name #1479

Closed as not planned
Closed as not planned
@grumpyp

Description

@grumpyp

Setup

Running onGitPython==3.1.27

MacOS monterey,Python 3.10.5

Reproduce the bug

git checkout <commit> -> leads to a detached HEAD

from pathlib import Pathfrom git import Repodef 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.pyTraceback (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

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp