cli / cli/cli

`gh pr checkout` should add the fork as a remote

Open
#2,942 34 comments 39 reactions 0 assignees View on GitHub
enhancement gh-pr pitch
Dominant language
Go
Stars
46.3k
Forks
9k
Avg merge
2d 9h
Merged PRs (30d)
89

Description

# CLI Feedback

## What have you loved?

`gh pr checkout` is one of the best features of this tool, thanks!

## What was confusing or gave you pause?

I had a PR I created elsewhere to an org repo, requesting changes from my own fork's branch, e.g.:

`upstream` has PR `#2` with changes from `origin:patch-1` branch to `upstream:main`.

In a new computer I clone the repo with `gh clone org/project`, then on the project's folder, I checkout the PR's work with `gh pr checkout 2`. It gets me on the `patch-1` branch, but my `git remote` still points only the the org's remote, not to my fork's remote.

__My issue__ happened when I applied changes to the branch and tried to push it back. It's a minor problem but I can tell that using `git remote add leobalter git@github.com:leobalter/.git` is something that I'd love to avoid when I use `gh pr checkout`.

## Are there features you'd like to see added?

I'd love if `gh pr checkout` could add the remote by default if it's not listed in the known remotes, or at least offer me an option to add it. This would allow a quick way to set the new branch to track the proper remote branch as well.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.