Title: Init script makes slightly confusing reflog if multiple remotes have "master" · Issue #2145 · gitpython-developers/GitPython · GitHub
Open Graph Title: Init script makes slightly confusing reflog if multiple remotes have "master" · Issue #2145 · gitpython-developers/GitPython
X Title: Init script makes slightly confusing reflog if multiple remotes have "master" · Issue #2145 · gitpython-developers/GitPython
Description: Background This code in the init script runs this to check out the master branch if present and readily available, and other just make a branch called that where we are now: GitPython/init-tests-after-clone.sh Lines 42 to 43 in 7b83f7a #...
Open Graph Description: Background This code in the init script runs this to check out the master branch if present and readily available, and other just make a branch called that where we are now: GitPython/init-tests-af...
X Description: Background This code in the init script runs this to check out the master branch if present and readily available, and other just make a branch called that where we are now: GitPython/init-tests-af...
Opengraph URL: https://github.com/gitpython-developers/GitPython/issues/2145
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Init script makes slightly confusing reflog if multiple remotes have \"master\"","articleBody":"#### Background\n\nThis code in the init script runs this to check out the `master` branch if present and readily available, and other just make a branch called that where we are now:\n\nhttps://github.com/gitpython-developers/GitPython/blob/7b83f7a99af4313264650339e08601834b3ca968/init-tests-after-clone.sh#L42-L43\n\nThat is intended to cover, and does cover, the cases where `master` is available locally, or not available locally but available from one remote.\n\nThe `master` branch in GitPython is basically only for testing, and this has been so for some years. The default branch is `main`. The `master` branch is mostly just a ref for testing, and there is a lot of flexibility in where it points. The test suite needs a reflog at least a few entries long, so:\n\nhttps://github.com/gitpython-developers/GitPython/blob/7b83f7a99af4313264650339e08601834b3ca968/init-tests-after-clone.sh#L45-L48\n\nThen `master` is reset to wherever we started anyway. The reason for all this, of course, is that the test suite uses the current repository (of GitPython itself, as well as its submodules) in test fixtures. I think we intend to change that at some point, but it has to be done carefully, so this intended high coupling between the test suite and the local GitPython repository remains for now.\n\n#### When multiple remotes have it\n\nWhen multiple remotes have a `master` branch and no local `master` branch exists, Git configuration determines what happens. But by default, an attempt to switch to a locally absent branch that is to be set up automatically from a remote will refuse to proceed if there is more than one, even if they point to the same commit.\n\nAs a result, we get:\n\n```text\nek@ELIAHKAGAN76BA CLANGARM64 /e/repos/GitPython (main)\n$ ./init-tests-after-clone.sh\nThis operation will destroy locally modified files. Continue ? [N/y]: y\nhint: If you meant to check out a remote tracking branch on, e.g. 'origin',\nhint: you can do so by fully qualifying the name with the --track option:\nhint:\nhint: git checkout --track origin/\u003cname\u003e\nhint:\nhint: If you'd like to always have checkouts of an ambiguous \u003cname\u003e prefer\nhint: one remote, e.g. the 'origin' remote, consider setting\nhint: checkout.defaultRemote=origin in your config.\nfatal: 'master' matched multiple (2) remote tracking branches\nSwitched to a new branch 'master'\nHEAD is now at c7648c0c Merge pull request #2143 from gitpython-developers/contrbuting\nHEAD is now at 5a294a6f bump version to 3.1.50\nHEAD is now at d7b029f1 Merge pull request #2142 from gitpython-developers/fix-validate-config-key-newlines\nHEAD is now at 7b83f7a9 Merge pull request #2144 from mvanhorn/osc/2016-clarify-execute-string-arg\nSubmodule 'gitdb' (https://github.com/gitpython-developers/gitdb.git) registered for path 'git/ext/gitdb'\nCloning into 'E:/repos/GitPython/git/ext/gitdb'...\nSubmodule path 'git/ext/gitdb': checked out '335c0f66173eecdc7b2597c2b6c3d1fde795df30'\nSubmodule 'smmap' (https://github.com/gitpython-developers/smmap.git) registered for path 'git/ext/gitdb/gitdb/ext/smmap'\nCloning into 'E:/repos/GitPython/git/ext/gitdb/gitdb/ext/smmap'...\nSubmodule path 'git/ext/gitdb/gitdb/ext/smmap': checked out 'c6b53d35deb82a38d5d07ca7712c1334a7a10c10'\nFetching origin\nFetching upstream\nFetching kip\n```\n\nThis is mostly harmless, and arguably completely harmless. The only actual significant effect that would ordinarily occur is that the resets, done to ensure a deep enough reflog for reflog-related tests, are populated from more recent history.\n\nHowever, it is unintuitive that adding (and fetching from) multiple remotes with `master` would affect which reflog entries the init script populates.\n\n#### The fix\n\nIt should be enough to add a comment describing the behavior. There is probably no simple always-right thing to do besides that. It's probably excessively complex to treat the case where all upstream `master` branches reference the same commit specially. The bug, if it can be called that, is in the confusion about what reflog entries are populated.\n\nIf I don't identify any more serious effect of this, then I'll make that change, possibly as part of some larger PR.\n\n#### Meta-discussion\n\nI guess this a liminal case of an issue. I almost didn't report it. But I didn't want to forget it. In particular, whenever the test suite is changed to be less coupled with the checked-out GitPython repository itself, the precise semantics of the init script may be important, so I think it's best they be as clear as possible.","author":{"url":"https://github.com/EliahKagan","@type":"Person","name":"EliahKagan"},"datePublished":"2026-05-07T18:47:39.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/2145/GitPython/issues/2145"}
| 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:9a5e2f4e-7adf-4c87-63ee-2edb3bc5ed1a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CFA4:3F2674:11F4A2E:19B6C85:6A58E671 |
| html-safe-nonce | ca5d90353f0cd36d3ebba117ffaa3874aa45cd8180ac769f4568a9997f7b4798 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRkE0OjNGMjY3NDoxMUY0QTJFOjE5QjZDODU6NkE1OEU2NzEiLCJ2aXNpdG9yX2lkIjoiNzcyNDU0NDc3MjkzNDI2NDQzNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ccc68d353690594ae9fde2e399a5f88808466dfbb3baab4e287560bb4cfb7f8d |
| hovercard-subject-tag | issue:4401190930 |
| 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/2145/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a3d1c1db097211f1740dee0a69b0ac5285288a449fa3d43305a495a317f2403c/gitpython-developers/GitPython/issues/2145 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a3d1c1db097211f1740dee0a69b0ac5285288a449fa3d43305a495a317f2403c/gitpython-developers/GitPython/issues/2145 |
| og:image:alt | Background This code in the init script runs this to check out the master branch if present and readily available, and other just make a branch called that where we are now: GitPython/init-tests-af... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | EliahKagan |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f2a0c7865178af3d91dd9f13b0cdfc3c73a2529c873d2780bb4c01271a57ec6 |
| 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 | 8aae7b8d6caacacf5c66eaeb2702d8dc88d85b4a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width