1

Using GitHub gh, how do I create a PR eg

gh pr create --repo "owner/repo" --title "PR title" --body "PR body"

when not CD'd to the local repo. When I run this command from an arbitrary directory, I get "failed to run git: fatal: not a git repository (or any of the parent directories): .git" So gh is trying to run git behind the scene. The owner/repo I think is the remote repo, but I'm looking for a parameter to specify which local repo to use, like git -C "repo".

torek
  • 448,244
  • 59
  • 642
  • 775
wavefront
  • 41
  • 3

1 Answers1

1

This is reported by issue 5465 and followed by issue 5075

Maybe using GH_REPO (as requested in issue 5061) can help (gh 2.5.1+), but only with gh api.

If not, doing a manual cd first seems the only option.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Closer but not quite there. This works perfectly fine for "remote only" commands like `GH_REPO=owner/repo gh pr list` but to create a PR you need to specify what branch you are on. So the missing bit is the equivalent of `cd localGitRepo; git checkout branchName`. Thanks for advice – wavefront Oct 27 '22 at 07:46
  • @wavefront I suspect https://github.com/cli/cli/issues/5465#issuecomment-1143781469 shows a similar issue indeed. – VonC Oct 27 '22 at 10:07