Gihub CLI 错误:必须位于名称与“master”不同的分支上

发布于 2025-01-13 17:48:14 字数 314 浏览 3 评论 0原文

我想使用 GitHub CLI 工具 (gh) 将 staging 分支与 master 同步。因此,我在本地的 master 分支上运行此命令:

gh pr create -b staging -t "master -> staging"

但收到此错误:

必须位于名称与“master”不同的分支上

我对 GitHub CLI 仍然很陌生,我不确定为什么需要有一个不同名称的分支。

I want to sync staging branch with master using GitHub CLI tool (gh). So I am on the master branch locally and I run this command:

gh pr create -b staging -t "master -> staging"

but I receive this error:

must be on a branch named differently than "master"

I am still new to GitHub CLI and I am not sure why I need to have a branch different name.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

伪心 2025-01-20 17:48:14

默认情况下, gh pr create 使用当前签出的分支作为包含拉取请求提交的分支 (head)。因此,您的命令尝试创建从 mastermaster 的 PR,这是不可能的。

您可以使用 headbase 参数创建所需的 PR(将 master 合并到 staging),如下所示:

gh pr create --head master --base staging

如果您当前位于 master 分支,则可以省略 head 参数:

gh pr create --base staging

两种方式都会导致以下结果:
结果


旁注:在您的问题中,您使用的是 -b staging,它是 --body staging 的缩写。 --base staging 的正确简写是 -B staging

By default, gh pr create uses the currently checked out branch as the branch containing the commits for your pull request (head). Consequently, your command tries to create a PR from master to master which is not possible.

You can use the head and base parameters to create the desired PR (merging master into staging) like this:

gh pr create --head master --base staging

If you are currently on the master branch, you can omit the head parameter:

gh pr create --base staging

Both ways result in this:
result


Sidenote: In your question you are using -b staging which is short for --body staging. The correct shorthand for --base staging would be -B staging.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文