Title: Repo instantiated from a bare-repository worktree incorrectly sets `bare = True` · Issue #2223 · gitpython-developers/GitPython · GitHub
Open Graph Title: Repo instantiated from a bare-repository worktree incorrectly sets `bare = True` · Issue #2223 · gitpython-developers/GitPython
X Title: Repo instantiated from a bare-repository worktree incorrectly sets `bare = True` · Issue #2223 · gitpython-developers/GitPython
Description: Title Repo instantiated from a bare-repository worktree incorrectly sets bare = True Description Since 3.1.58+, instantiating a git.Repo targeting a working tree folder that was created from a bare repository (via git worktree add) inher...
Open Graph Description: Title Repo instantiated from a bare-repository worktree incorrectly sets bare = True Description Since 3.1.58+, instantiating a git.Repo targeting a working tree folder that was created from a bare...
X Description: Title Repo instantiated from a bare-repository worktree incorrectly sets bare = True Description Since 3.1.58+, instantiating a git.Repo targeting a working tree folder that was created from a bare...
Opengraph URL: https://github.com/gitpython-developers/GitPython/issues/2223
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Repo instantiated from a bare-repository worktree incorrectly sets `bare = True`","articleBody":"### Title\nRepo instantiated from a bare-repository worktree incorrectly sets `bare = True` \n\n### Description\nSince 3.1.58+, instantiating a `git.Repo` targeting a working tree folder that was created from a bare repository (via `git worktree add`) inherits the `bare = True` setting from the main repository's `.git` location.\n\nThis causes `repo.working_tree_dir` to resolve to `None`, which causes operations like `index.add()` / `_entries_for_paths` to fail with:\n`InvalidGitRepositoryError: Cannot rewrite paths without a working tree`\n\n### Minimal Reproduction Example\n```python\nfrom git import Repo\nimport subprocess, tempfile, os\n\nwith tempfile.TemporaryDirectory() as tmpdir:\n bare_path = os.path.join(tmpdir, \"bare.git\")\n worktree_path = os.path.join(tmpdir, \"wt\")\n \n # 1. Init bare repo and add a commit\n repo_bare = Repo.init(bare_path, bare=True)\n \n # 2. Add a worktree\n repo_bare.git.worktree(\"add\", \"-b\", \"main\", worktree_path)\n \n # 3. Open worktree repo\n wt_repo = Repo(worktree_path)\n \n # Expected: wt_repo.bare is False, wt_repo.working_tree_dir is worktree_path\n # Actual: wt_repo.bare is True, wt_repo.working_tree_dir is None\n print(\"Is bare:\", wt_repo.bare)\n print(\"Working tree dir:\", wt_repo.working_tree_dir)\n\nIs bare: True\nWorking tree dir: None\n\nwhile using 3.1.57 the same code produces the correct results\nIs bare: False\nWorking tree dir: /tmp/tmpgz7gz3y6/wt","author":{"url":"https://github.com/isomogyi","@type":"Person","name":"isomogyi"},"datePublished":"2026-09-01T06:59:47Z","url":"https://github.com/gitpython-developers/GitPython/issues/2223"}
| 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:3447b3ac-cfc6-5a07-cd48-55c32b87bd96 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8FD8:3897F3:688F6A:895DDA:6B00D39F |
| html-safe-nonce | 99e3e6692e8651ba568beafb6076989e5a386220185e85bd4809af879204dbd4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RkQ4OjM4OTdGMzo2ODhGNkE6ODk1RERBOjZCMDBEMzlGIiwidmlzaXRvcl9pZCI6Ijg3NjY3OTk1MjE2ODMzOTU0ODciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 03240c9e9afcac706a8d85b6d8db58d0318c03efeadb1f4a0993726e6deff065 |
| hovercard-subject-tag | issue:5308796273 |
| 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/2223/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9d97bacdf772ce2d56fff8595525fafa0bda168a2216b0be429135d070889396/gitpython-developers/GitPython/issues/2223 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9d97bacdf772ce2d56fff8595525fafa0bda168a2216b0be429135d070889396/gitpython-developers/GitPython/issues/2223 |
| og:image:alt | Title Repo instantiated from a bare-repository worktree incorrectly sets bare = True Description Since 3.1.58+, instantiating a git.Repo targeting a working tree folder that was created from a bare... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | isomogyi |
| hostname | github.com |
| expected-hostname | github.com |
| None | 85bbdfe2b6ba16e234513bc6ceff5d848ef8449820c900692a2b4e67061931e5 |
| 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 | 4943239a6d2c591325dad6e5c313e1cafda877f6 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width