如何使用新的 github cli 向远程仓库发出合并请求而不推送远程分支?

How to make a Pull Request using the new github cli, to a remote repo without pushing a remote branch too?

我想弄清楚如何从本地分支(甚至从本地 master/main 分支)向我的远程存储库发出 PR。但是,无论我做什么,我都会收到以下错误:

来自 本地的尝试 main:

(master)$ gh pr create --title "Adding readme" --body "Testing pr from cli" --head armsp:feature

Creating pull request for armsp:feature into master in armsp/----

pull request create failed: GraphQL error: Head sha can't be blank, Base sha can't be blank, No commits between master and feature, Head ref must be a branch

本地 feature 分支尝试:

(feature)$ gh pr create --title "Adding readme" --body "Testing pr from cli" --head armsp:feature

Creating pull request for armsp:feature into master in armsp/----

pull request create failed: GraphQL error: Head sha can't be blank, Base sha can't be blank, No commits between master and feature, Head ref must be a branch

整个情况的大致步骤是-

  1. 将一些文件从本地 main 提交并推送到远程 main
  2. 创建一个新的本地分支feature,编辑一些东西,提交
  3. 公关
    1. 使用本地分支gh--head论证直接向远程发起PR,而无需创建相同的远程分支
    2. 使用本地 master gh--head 参数而不创建远程分支

我在 github cli repo 上看到了几个问题,它们似乎已在发行版中修复,但不幸的是,它仍然对我不起作用。

我的gh版本

$ gh version
gh version 1.2.1 (2020-11-11)

注意:我必须通过 terminal/cli.

完成 PR

不行,你至少应该先在远程创建一个分支。

what is a Pull Request in Git vs GitHub上强制介绍后,我将引用以下内容:

Pull requests let you tell others about changes you've pushed to a branch in a repository on GitHub. Once a pull request is opened, you can discuss and review the potential changes with collaborators and add follow-up commits before your changes are merged into the base branch. source.

GitHub PR 期望远程 GitHub 服务器上的 一些 代码,至少一个分支。

Create a pull request to propose and collaborate on changes to a repository. These changes are proposed in a branch, which ensures that the default branch only contains finished and approved work. source.

您希望在远程为不存在的分支打开合并请求。先创建分支,然后重试。请记住,您无法让远程自动从本地获取或拉取内容到远程,因此最后您必须推送它。