← 返回首页
Document init script behavior with multiple master remotes by EliahKagan · Pull Request #2148 · gitpython-developers/GitPython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

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

Provide feedback

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

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

Document init script behavior with multiple master remotes#2148

Merged
EliahKagan merged 1 commit into
gitpython-developers:mainfrom
EliahKagan:claude/gifted-booth-e5e2b4
May 10, 2026
Merged

Document init script behavior with multiple master remotes#2148
EliahKagan merged 1 commit into
gitpython-developers:mainfrom
EliahKagan:claude/gifted-booth-e5e2b4

Conversation

Copy link
Copy Markdown
Member

EliahKagan commented May 10, 2026
edited
Loading

Summary

  • Add a comment to init-tests-after-clone.sh explaining what happens when master is locally absent but present on more than one remote: git checkout master -- refuses to pick one (even when all of the remote-tracking branches agree on a commit), and the script falls back to git checkout -b master, creating the branch at the current HEAD. The reflog built up by the subsequent git reset --hard HEAD~1 calls then traces HEAD's history instead of a remote master's. This is harmless because master is reset to __testing_point__ afterward, but it is unintuitive enough to be worth noting in the script itself.

Closes #2145.

Test plan

  • sh -n init-tests-after-clone.sh passes
  • shellcheck init-tests-after-clone.sh passes
  • Diff is comment-only; no behavior change

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings May 10, 2026 01:50
EliahKagan marked this pull request as draft May 10, 2026 01:50
EliahKagan force-pushed the claude/gifted-booth-e5e2b4 branch from 7a03e10 to b5ae6c0 Compare May 10, 2026 01:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

Pull request overview

Adds in-script documentation clarifying an unintuitive git checkout master -- || git checkout -b master edge case when multiple remotes provide a master branch, so future contributors understand why master’s reflog may end up reflecting HEAD history during test initialization (Closes #2145).

Changes:

  • Document how git checkout master -- can fail due to ambiguous remote-tracking branches when master is missing locally and multiple remotes have it.
  • Explain that the script then creates master at the current HEAD, affecting which history the reflog-reset sequence records (before resetting back to __testing_point__).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread init-tests-after-clone.sh Outdated Show resolved Hide resolved
When `master` is locally absent and more than one remote has it, `git checkout master --` fails by default even if all remotes agree, and the script falls back to creating `master` at `HEAD`. The reflog populated by the subsequent resets then traces `HEAD`'s history rather than a remote `master`'s. This is harmless, because `master` is reset to `__testing_point__` either way, but unintuitive. Add a comment so a reader of the script does not have to discover this from a confusing run. This fixes gitpython-developers#2145. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread init-tests-after-clone.sh Show resolved Hide resolved
Copy link
Copy Markdown
Member Author

EliahKagan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

I didn't think of a better way to deal with this besides adding a comment. Also, I had originally thought of including this as part of some larger PR, but it doesn't really fit nicely in with any of the other forthcoming GitPython PRs I'm working on. So I'm doing it by itself. I think this at least better than not expanding the comment, and I plan to merge this once CI passes.

Copy link
Copy Markdown
Member Author

Incidentally, I decided to try to have Claude Code proceed in its default way, rather than articulating a plan first. Overall, this is faster but kind of rough: for example, the branch name is meaningless, which is something I try to avoid. I don't think the branch name is worth the noise and churn of remaking the PR, though.

EliahKagan marked this pull request as ready for review May 10, 2026 02:13
Hide details View details EliahKagan merged commit acb6d56 into gitpython-developers:main May 10, 2026
34 checks passed
EliahKagan deleted the claude/gifted-booth-e5e2b4 branch May 10, 2026 02:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Init script makes slightly confusing reflog if multiple remotes have "master"

2 participants

Footer

© 2026 GitHub, Inc.