cajias/claude-skills/gh-pr-create-must-push-error

Claude Code and agent skill by cajias/claude-skills

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Fix for "aborted: you must first push the current branch to a remote, or use the --head flag" from `gh pr create` when the branch IS already pushed. Use when: (1) `git push -u origin <branch>` succeeded moments earlier, (2) `git branch -vv` shows upstream tracking is set, (3) `gh pr create` still rejects with the must-push message. Workaround: pass `--head <branch>` explicitly.

Install

npx vskill@latest install cajias/claude-skills/gh-pr-create-must-push-error

SKILL.md

The same SKILL.md was published earlier as cajias/claude-skills/gh-pr-create-must-push-error.

gh pr create "must first push" False Error

Problem

gh pr create reports:

text
aborted: you must first push the current branch to a remote, or use the --head flag

even though the branch has just been pushed successfully and git branch -vv shows correct upstream tracking.

Context / Trigger Conditions

  • git push -u origin <branch> completed without error moments ago
  • git remote -v shows the expected remote
  • git branch -vv shows [origin/<branch>] upstream tracking
  • Remote URL uses SSH (git@github.com:...) — more likely but not required
  • Typically seen when pushing a freshly-created branch in the same session

gh appears to consult a cache of remote ref state that hasn't refreshed between the push and the immediate gh pr create call.

Solution

Pass --head <branch-name> explicitly:

bash
gh pr create --head fix/my-branch --title "..." --body "..."

This bypasses the stale "is this branch pushed?" check and uses the named branch directly. The PR is created against the default base branch unless --base is also passed.

Verification

The command returns the PR URL (e.g., https://github.com/owner/repo/pull/42) instead of the abort message.

Example

bash
# Push just succeeded
git push -u origin fix/frontmatter-schema-alignment
# => * [new branch] fix/frontmatter-schema-alignment -> fix/frontmatter-schema-alignment
# Immediate PR create fails
gh pr create --title "feat: ..." --body "..."
# => aborted: you must first push the current branch to a remote, or use the --head flag
# With --head: succeeds
gh pr create --head fix/frontmatter-schema-alignment --title "feat: ..." --body "..."
# => https://github.com/owner/repo/pull/4

Notes

  • Alternative workarounds reported in issues: wait a few seconds and retry,

or run git fetch before gh pr create. --head is the fastest and most reliable.

  • This is not the same as the "no commits between" error — that one means

the branch really does match the base. Read the exact error text.

  • If --head _also_ fails with a different error (e.g., "could not determine

base branch"), pass --base main explicitly too.

References

class of race condition, with --head as the documented workaround

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
5

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/cajias/claude-skills/gh-pr-create-must-push-error/badge)](https://verified-skill.com/skills/cajias/claude-skills/gh-pr-create-must-push-error)

Something wrong with this skill or its page? Tell us.