Use GitHub CLI to raise PR to upstream

Viewed 981

How can I raise a PR from my forked repo's development branch to upstream repo's development branch. I tried the gh pr create, but gave me following output/error

$ gh pr create
Warning: 3 uncommitted changes

Creating pull request for development into development in upstream-repo-org/upstream-repo

? Title permission check for edit feature moved to parent components   
? Body <Received>
? What's next? Submit
pull request create failed: GraphQL error: No commits between development and development
2 Answers

Yes, that is reported and followed by cli/cli issue 1820.

It stems from the new version 1.0.0:

they have changed the implementation for gh pr create: #1706
Quote from the PR:

We no longer try to guess which is a suitable push target for the "head" branch.
Instead, unless the user has already fully pushed their branch, we always present the user with a prompt:
We never fork nor push without explicit user agreement anymore.

This is also linked to issue 1762: "Breaking behavior change: pushing topic branch to wrong remote"

A PR was in progress to fix this: PR 1926: Fix pr create when branch was already pushed to a non-base remote.

Bonus: also proposes a new command stubber for tests, one that matches commands by their invocation instead of sequentially and also asserts that all stubs have matched at the end of the test.

This is fixed with gh 1.1.0, with gh pr create

gh pr create \
  --repo <[HOST/]OWNER/REPO>
  --head <yourRepo>:<yourFeatureBranch> \
  --base <The branch into which you want your code merged>

<xx> is a placeholder to be replaced (meaning there should be no < and > in the final command)

You can push to upstream repo from your local branch on forked Repo using the below.

gh pr create -R {Upstream_Org}/{repoName} -H {YourRepo}:{your_feature_branch} --base {Upstream_branch_against_which_pr_should_be_raised}
Related