Title: checking out a detached HEAD breaks Repo.head.reference · Issue #2230 · gitpython-developers/GitPython · GitHub
Open Graph Title: checking out a detached HEAD breaks Repo.head.reference · Issue #2230 · gitpython-developers/GitPython
X Title: checking out a detached HEAD breaks Repo.head.reference · Issue #2230 · gitpython-developers/GitPython
Description: While building this package for openSUSE and running the testsuite we encountered a lot of test failures like this self =
Open Graph Description: While building this package for openSUSE and running the testsuite we encountered a lot of test failures like this self =
X Description: While building this package for openSUSE and running the testsuite we encountered a lot of test failures like this self = <git.HEAD "HEAD"> def _get_reference(self) -> "Refe...
Opengraph URL: https://github.com/gitpython-developers/GitPython/issues/2230
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"checking out a detached HEAD breaks Repo.head.reference","articleBody":"While building this package for openSUSE and running the testsuite we encountered a lot of test failures like this\n\n```\nself = \u003cgit.HEAD \"HEAD\">\n\n def _get_reference(self) -> \"Reference\":\n \"\"\"\n :return:\n :class:`~git.refs.reference.Reference` object we point to\n\n :raise TypeError:\n If this symbolic reference is detached, hence it doesn't point to a\n reference, but to a commit.\n \"\"\"\n sha, target_ref_path = self._get_ref_info(self.repo, self.path)\n if target_ref_path is None:\n> raise TypeError(\"%s is a detached symbolic reference as it points to %r\" % (self, sha))\nE TypeError: HEAD is a detached symbolic reference as it points to '3481da9618e69063464c94447167d83bd45505a9'\n\ngit/refs/symbolic.py:446: TypeError\n```\n\nIt seems that this only occurs when checking out a revision instead of a branch, aka when the ref in .git/HEAD points to a commit instead of something like `ref: refs/heads/master`.\n\nRepo.head.reference in git/repo/base.py fails to resolve references to commit hashes which I would expect to work.\n\nAlso there is an unrelated problem where TestRemote.test_base hardcodes the branch name as \"master\" which leads to the test failing when checking out any other branch.","author":{"url":"https://github.com/tiltingpenguin","@type":"Person","name":"tiltingpenguin"},"datePublished":"2026-09-09T09:33:01Z","url":"https://github.com/gitpython-developers/GitPython/issues/2230"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6589b21a-96f8-9257-ad2d-6a842be4521b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A480:6365:4157EC:599928:6B00CB20 |
| html-safe-nonce | 77b8f441ff183a879f872235a7928740ce6419e3ceec84c49112c6c49f60d215 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNDgwOjYzNjU6NDE1N0VDOjU5OTkyODo2QjAwQ0IyMCIsInZpc2l0b3JfaWQiOiIyNTUxNjA3NjE5NTc1OTI1NTM2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 6133d5b2d8997225e2b827ac72c716a8ddee2b9a0d7befbebe79a90368c9d3e7 |
| hovercard-subject-tag | issue:5397653760 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/gitpython-developers/GitPython/2230/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0280c434d256f72b50e27047a4464721100d4e4adc2f01700bed8c4d3a9bf8db/gitpython-developers/GitPython/issues/2230 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0280c434d256f72b50e27047a4464721100d4e4adc2f01700bed8c4d3a9bf8db/gitpython-developers/GitPython/issues/2230 |
| og:image:alt | While building this package for openSUSE and running the testsuite we encountered a lot of test failures like this self = |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tiltingpenguin |
| hostname | github.com |
| expected-hostname | github.com |
| None | 98dc00e171c204462a6f367482a0f8c3c6b5dbca99cd7390e82d2df49ce096e4 |
| turbo-cache-control | no-preview |
| go-import | github.com/gitpython-developers/GitPython git https://github.com/gitpython-developers/GitPython.git |
| octolytics-dimension-user_id | 503709 |
| octolytics-dimension-user_login | gitpython-developers |
| octolytics-dimension-repository_id | 1126087 |
| octolytics-dimension-repository_nwo | gitpython-developers/GitPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1126087 |
| octolytics-dimension-repository_network_root_nwo | gitpython-developers/GitPython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ef013399cf0a3c324bea644a685d7c1e0f06b5b7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width