Repository navigation
git feature new: record a base branch when started from a detached HEAD - #40
Merged
Merged
Conversation
Worktrees made with `git worktree add --detach <path> origin/main` left nothing recorded, so `git pullrequest` had to ask, and in a script it gave up. - Detached at the tip of origin/<masterBranch> (or the local one): record masterBranch without asking. - Detached elsewhere: ask which branch, default masterBranch, check it is on origin. No answer on stdin: exit before creating the branch, asking for --base. - `git feature new <name> --base <branch>` records the base without asking. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Worktrees made with
git worktree add --detach ../<repo>-eng-NNNN origin/mainand thenecho y | git feature new <branch>recorded no base branch._record_base_if_branchonly recorded a local branch, and the reflog says onlyCreated from HEAD. Sogit pullrequestasked "Was it main?", and in a script it gave up. All 11 Harper ENG-2110 PRs neededgit pullrequest --base main.Behaviour
origin/<masterBranch>or the localmasterBranchmasterBranchwithout asking, and skips the "You aren't on your main branch" questionHEAD is detached. Which branch is <new_branch> based on? [<masterBranch>](Enter =masterBranch), checks the answer is on originecho y | git feature new x)no answer on stdin. Rerun with --base <branch>…. Never guessesgit feature new <name> --base <branch><branch>(must be on origin), asks nothing, matchinggit pullrequest --basegit release new/git hotfix new(_branch_func) get the same detached-HEAD handling, but not--base.Changes
gitfeatures/core.py:_record_base_if_branchis replaced by_detached_at_master_tipand_base_for_new_branch, which reuse_ref_exists,_record_base_branchand the existing "not on origin" message. The base is resolved beforegit checkout -b, so a bad answer leaves nothing behind.tests/test_feature_new.py: 5 cases (detached at the master tip, prompt answered, answer not on origin, no answer on stdin,--base).git feature newreference, and a troubleshooting entry. CHANGELOG: a "Fixed" entry.Testing
pytest: 82 passed. flake8, black (-l 119) and rst-lint are clean.No version bump.
🤖 Generated with Claude Code