Skip to content

fix: detect default branch in gitissue instead of hardcoding master#28

Merged
RWejlgaard merged 1 commit into
masterfrom
fix-gitissue-default-branch
Jun 23, 2026
Merged

fix: detect default branch in gitissue instead of hardcoding master#28
RWejlgaard merged 1 commit into
masterfrom
fix-gitissue-default-branch

Conversation

@RWejlgaard

Copy link
Copy Markdown
Owner

What

gitissue (in config/fish/functions.fish) hardcoded master — it ran git checkout master and git pull origin master. On any repo whose default branch is main (now the common default) or anything else, both commands fail and you're left on the wrong branch after a git reset --hard has already discarded your work.

Change

  • Detect the remote's default branch from origin/HEAD (git symbolic-ref --short refs/remotes/origin/HEAD) and use that for the checkout/pull.
  • If it can't be resolved (e.g. origin/HEAD not set), bail out before the destructive git reset --hard with a hint to run git remote set-head origin -a.

Testing

  • fish --no-execute config/fish/functions.fish passes (same check CI runs).
  • Verified the detection logic resolves the default branch correctly in fish.

🤖 Generated with Claude Code

`gitissue` always checked out and pulled `master`, so it failed on any
repo whose default branch is `main` (or anything else). Resolve the
remote's default branch from `origin/HEAD` and use that, bailing out
with a helpful message if it can't be determined.
@RWejlgaard RWejlgaard merged commit ac467a0 into master Jun 23, 2026
5 checks passed
@RWejlgaard RWejlgaard deleted the fix-gitissue-default-branch branch June 23, 2026 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant