您可以从 GitHub 上的命令行发出拉取请求吗?

发布于 2024-09-29 20:05:57 字数 41 浏览 14 评论 0 原文

似乎您必须与 github.com 交互才能发起拉取请求。是这样吗?

It seems like you have to interact with github.com to initiate a pull request. Is this so?

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

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

发布评论

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

评论(12

偏爱你一生 2024-10-06 20:05:57

更新hub命令现已成为官方github项目,并且还支持创建拉取请求

原始

似乎是一个特别有用的东西添加到 hub 命令:http://github.com/defunkt/hub 或 github gem:< a href="http://github.com/defunkt/github-gem" rel="noreferrer">http://github.com/defunkt/github-gem

我建议向这些项目提出问题为了它。 github 上的人反应非常灵敏。

UPDATE: The hub command is now an official github project and also supports creating pull requests

ORIGINAL:

Seems like a particularly useful thing to add to the hub command: http://github.com/defunkt/hub or the github gem: http://github.com/defunkt/github-gem

I suggest filing an issue with those projects asking for it. The github guys are pretty responsive.

莫言歌 2024-10-06 20:05:57

Git 现在附带一个子命令 <​​code>'git request-pull' [-p] ; <网址> []

查看文档

您可以在此处 可能会发现这很有用,但它与 GitHub 的功能并不完全相同

Git now ships with a subcommand 'git request-pull' [-p] <start> <url> [<end>]

You can see the docs here

You may find this useful but it is not exactly the same as GitHub's feature.

北方的韩爷 2024-10-06 20:05:57

使用 Hub 命令行包装器,您可以将其链接到 git,然后您可以执行以下操作
git pull-request

从 hub 的手册页:

   git pull-request [-f] [TITLE|-i ISSUE|ISSUE-URL] [-b BASE] [-h HEAD]
          Opens a pull request on GitHub for the project that the "origin" remote points to. The default head of the pull request is the current branch. Both base and head of the pull request can be explicitly given in one  of  the  following  formats:  "branch",  "owner:branch",
          "owner/repo:branch". This command will abort operation if it detects that the current topic branch has local commits that are not yet pushed to its upstream branch on the remote. To skip this check, use -f.

          If TITLE is omitted, a text editor will open in which title and body of the pull request can be entered in the same manner as git commit message.

          If instead of normal TITLE an issue number is given with -i, the pull request will be attached to an existing GitHub issue. Alternatively, instead of title you can paste a full URL to an issue on GitHub.

With the Hub command-line wrapper you can link it to git and then you can do
git pull-request

From the man page of hub:

   git pull-request [-f] [TITLE|-i ISSUE|ISSUE-URL] [-b BASE] [-h HEAD]
          Opens a pull request on GitHub for the project that the "origin" remote points to. The default head of the pull request is the current branch. Both base and head of the pull request can be explicitly given in one  of  the  following  formats:  "branch",  "owner:branch",
          "owner/repo:branch". This command will abort operation if it detects that the current topic branch has local commits that are not yet pushed to its upstream branch on the remote. To skip this check, use -f.

          If TITLE is omitted, a text editor will open in which title and body of the pull request can be entered in the same manner as git commit message.

          If instead of normal TITLE an issue number is given with -i, the pull request will be attached to an existing GitHub issue. Alternatively, instead of title you can paste a full URL to an issue on GitHub.
歌入人心 2024-10-06 20:05:57

一个男人的搜索就像...

man git | grep pull | grep request

给出

git request-pull <start> <url> [<end>]

但是,尽管有这个名字,但这不是你想要的。根据文档:

生成一个请求,要求您的上游项目将更改拉入
他们的树。打印到标准输出的请求以
分支描述,总结更改并指出它们的来源
可以拉。

@HolgerJust 提到 github cli 可以实现你想要的功能:

gh pull-request [user] [branch]

其他人提到了官方 hub通过github打包:

sudo apt-get install hub

或者

brew install hub 

然后

hub pull-request [-focp] [-b <BASE>] [-h <HEAD>]

A man search like...

man git | grep pull | grep request

gives

git request-pull <start> <url> [<end>]

But, despite the name, it's not what you want. According to the docs:

Generate a request asking your upstream project to pull changes into
their tree. The request, printed to the standard output, begins with the
branch description, summarizes the changes and indicates from where they
can be pulled.

@HolgerJust mentioned the github cli does what you want:

gh pull-request [user] [branch]

Others have mentioned the official hub package by github:

sudo apt-get install hub

or

brew install hub 

then

hub pull-request [-focp] [-b <BASE>] [-h <HEAD>]
为人所爱 2024-10-06 20:05:57

另外 github/hub,其中 充当 Git 的代理,您现在(2020 年 2 月)拥有 cli/cli

请参阅“增强您的命令行体验:GitHub CLI 现已处于测试阶段< /a>”

创建拉取请求

创建一个分支,进行多次提交以修复问题中描述的错误,然后使用 gh 创建拉取请求以共享您的贡献。

cli/cli公关创建 -- https://i1.wp.com/user-images.githubusercontent.com/10404068/74261506-35df4080-4cb0-11ea-9285-c41583009e6c.png?ssl=1

通过使用 GitHub CLI 创建拉取请求,当您还没有分叉时,它还会自动创建一个分叉,并推送您的分支并创建拉取请求以合并您的更改。


2020 年 4 月:“GitHub CLI 现在支持自动填充拉取请求和自定义配置"

根据我们的测试版用户提供的反馈,GitHub CLI 0.7 已经推出了一些最受强烈要求的增强功能。
自上一个次要版本 0.6 以来,有以下三个主要功能:

  • 通过 gh 配置集编辑器 [editor] 配置 gh 以使用您的首选编辑器。
  • 使用 gh config set git_protocol sshgh 配置为默认 SSH。
    默认的 Git 协议是 HTTPS。
  • 使用 gh pr create --fill 自动填充提交中拉取请求的标题和正文。

因此:

gh pr create --fill

In addition of github/hub, which acts as a proxy to Git, you now (February 2020) have cli/cli:

See "Supercharge your command line experience: GitHub CLI is now in beta"

Create a pull request

Create a branch, make several commits to fix the bug described in the issue, and use gh to create a pull request to share your contribution.

cli/cli pr creation  -- https://i1.wp.com/user-images.githubusercontent.com/10404068/74261506-35df4080-4cb0-11ea-9285-c41583009e6c.png?ssl=1

By using GitHub CLI to create pull requests, it also automatically creates a fork when you don’t already have one, and it pushes your branch and creates your pull request to get your change merged.


And in April 2020: "GitHub CLI now supports autofilling pull requests and custom configuration"

GitHub CLI 0.7 is out with several of the most highly requested enhancements from the feedback our beta users have provided.
Since the last minor release, 0.6, there are three main features:

  • Configure gh to use your preferred editor with gh config set editor [editor].
  • Configure gh to default to SSH with gh config set git_protocol ssh.
    The default Git protocol is HTTPS.
  • Autofill the title and body of a pull request from your commits with gh pr create --fill.

So:

gh pr create --fill
合久必婚 2024-10-06 20:05:57

我最终制作了自己的,我发现它比周围的其他解决方案效果更好。

https://npmjs.org/package/pullr

I ended up making my own, I find that it works better the other solutions that were around.

https://npmjs.org/package/pullr

(り薆情海 2024-10-06 20:05:57

我使用简单的别名来创建拉取请求,

alias pr='open -n -a "Google Chrome" --args "https://github.com/user/repo/compare/pre-master...nawarkhede:$(git_current_branch)\?expand\=1"'

I'm using simple alias to create pull request,

alias pr='open -n -a "Google Chrome" --args "https://github.com/user/repo/compare/pre-master...nawarkhede:$(git_current_branch)\?expand\=1"'
星星的轨迹 2024-10-06 20:05:57

您可以安装 github 官方 CLI 来创建 PR 并执行其他类型的 事物

设置:

gh auth login

创建 PR:

gh pr create

合并:

gh pr merge

You can install github official CLI to create PR and do other sort of things.

To setup:

gh auth login

To create PR:

gh pr create

To merge:

gh pr merge

三生路 2024-10-06 20:05:57

我最近创建了一个工具,它完全可以满足您的需求:

https://github.com/jd /git-pull-request

它可以在一个命令中自动执行所有操作,分叉存储库,推送 PR 等。如果您需要编辑/修复它,它还支持更新 PR!

I've created a tool recently that does exactly what you want:

https://github.com/jd/git-pull-request

It automates everything in a single command, forking the repo, pushing the PR etc. It also supports updating the PR if you need to edit/fix it!

漆黑的白昼 2024-10-06 20:05:57

我以前用过这个工具——虽然看起来需要先打开一个问题,但如果你使用 github 问题跟踪,它非常有用,并且确实简化了工作流程。 git open-pull 然后从您所在或选择的任何分支提交拉取请求。
https://github.com/jehiah/git-open-pull

编辑:看起来像您可以即时创建问题,因此该工具是一个很好的解决方案。

I've used this tool before- although it seems like there needs to be an issue open first, it is super useful and really streamlines workflow if you use github issue tracking. git open-pull and then a pull request is submitted from whatever branch you are on or select.
https://github.com/jehiah/git-open-pull

EDIT: Looks like you can create issues on the fly, so this tool is a good solution.

嘿哥们儿 2024-10-06 20:05:57

是的。您可以安装 hub CLI 实用程序。
在 MACOS 上: brew install hub

您需要一次性 GitHub 令牌才能登录。

用户->开发设置->个人代币->生成
(请参阅:https://github.com/settings/tokens

git checkout -b mybranch
hub pull-request -b master -h mybranch

#user:     your_user_name
#password: your_git_token

Yes. You can install the hub CLI util.
On MACOS: brew install hub

You need to have one time GitHub token for login.

User -> Dev settings -> Personal tokens -> Generate
(See: https://github.com/settings/tokens)

git checkout -b mybranch
hub pull-request -b master -h mybranch

#user:     your_user_name
#password: your_git_token
◇流星雨 2024-10-06 20:05:57

为什么不从 CLI 打开浏览器窗口来处理我的拉取请求?

假设您的 CLI 可以使用 open 命令打开浏览器窗口,您可以将此 git 别名添加到 ~/.gitconfig 中,它将打开一个新的浏览器窗口您的拉取请求:

[alias]
    pull-request = "!f() { \
        REPO_NAME=$(basename -s .git `git config --get remote.origin.url`); \
        BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD); \
        URL=\"https://github.com/YOUR_ORGANIZATION/$REPO_NAME/compare/$BRANCH_NAME?expand=1\"; \
        open \"$URL\"; \
    }; f"

只需将 YOUR_ORGANIZATION 替换为您的组织名称即可。

然后设置完毕后,使用:git pull-request

Why not open a browser window for my pull request from the CLI?

Assuming that your CLI can open a browser window with the open command, you can add this git alias to your ~/.gitconfig, and it will open a new browser window for your pull request:

[alias]
    pull-request = "!f() { \
        REPO_NAME=$(basename -s .git `git config --get remote.origin.url`); \
        BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD); \
        URL=\"https://github.com/YOUR_ORGANIZATION/$REPO_NAME/compare/$BRANCH_NAME?expand=1\"; \
        open \"$URL\"; \
    }; f"

just replace YOUR_ORGANIZATION with the name of your organization.

then after you set it up, use: git pull-request

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