gh pr push that the official gh CLI still doesn't have.
gh pr push has been requested since 2019
(150+ upvotes, still open). Until it ships in gh proper, this extension fills the gap:
$ gh prpush
pushed HEAD to fork (fix-thing)
The story behind it: Push to the pull request you are actually working on — the TechnoThatch journal piece on why
gh pr pushis still missing.
- Finds the PR for your current branch (
gh pr view). - Picks the right remote:
- cross-repository PR → the fork remote (matched by URL owner, then by remote name),
- same-repo PR → the repository's own remote, whatever it is called.
A remote named
upstreamworks just as well asorigin, and when both exist — your fork asorigin, the base repo asupstream— the push goes to the base repo.
- Runs
git push <remote> HEAD:refs/heads/<head-branch>.
That's it. No state, no config file — it asks gh and git and gets out of the way.
After gh pr checkout on a machine where the fork was never cloned, there is no
remote for the fork, and plain git push cannot know where to send the branch.
gh prpush fails with the exact command to run.
--add-remote does it for you:
$ gh prpush --add-remote
added remote somebody (https://github.com/somebody/gh-prpush.git)
pushed HEAD to somebody (fix-thing)
The remote is named after the fork owner and its URL comes from gh, so the
scheme matches the remotes you already have (HTTPS stays HTTPS — gh's
credential helper is HTTPS-only by default).
It also works in the state where gh pr view itself cannot find the pull
request: gh resolves the PR for the current branch through git's push-target
configuration, which it cannot do when the fork is not a registered remote
(cli/cli#2942). When that happens,
gh prpush falls back to gh pr list --head, which finds the same PR.
gh extension install technothatch/gh-prpush
Requires the GitHub CLI (gh) on your PATH. Prebuilt
static binaries are attached to every release for Linux (amd64/arm64/386),
macOS (amd64/arm64) and Windows (amd64/arm64); gh picks the right one
automatically.
If you prefer to build from source:
git clone https://github.com/technothatch/gh-prpush.git
cd gh-prpush
go build -o gh-prpush . # Windows: go build -o gh-prpush.exe .
gh extension install .Naming note: this is a
ghextension, so the command isgh prpush— notgh pr push. That's aghlimitation: extensions live in thegh <name>namespace, and the built-inprcommand can't be extended with new subcommands. If/when the feature lands inghitself (cli/cli#2189), it will begh pr push.
cd your-repo
gh pr checkout 123 # or whatever workflow you use
# ... commit your changes ...
gh prpush
Flags:
| Flag | Effect |
|---|---|
--force-with-lease |
push with --force-with-lease (safe-ish force push) |
--add-remote |
add the fork as a remote if it isn't registered yet, then push |
-h, --help |
show help |
go test ./...
go build .
The remote-picking logic is fully covered by unit tests with a fake command runner.
- Upstream issue: cli/cli#2189 — if/when
gh pr pushships natively, uninstall this extension. - Related upstream request: cli/cli#2942 —
gh pr checkoutshould add the fork as a remote.--add-remotedoes that part for the push.