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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4037928/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 09:21:46  来源:igfitidea点击:

Can you issue pull requests from the command line on GitHub?

gitgithubpull-request

提问by Andrew Johnson

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

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

采纳答案by kanaka

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

更新hub命令现在是一个官方的 github 项目,并且还支持创建拉取请求

ORIGINAL:

原文

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

添加到集线器命令似乎是一个特别有用的东西:http: //github.com/defunkt/hub或 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.

我建议向那些要求它的项目提出问题。github 的人非常敏感。

回答by Zensaburou

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

Git 现在附带一个子命令 '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.

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

回答by Flov

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

使用Hub 命令行包装器,您可以将其链接到 git,然后您可以执行 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.

回答by hobs

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.

生成一个请求,要求您的上游项目将更改拉入他们的树中。打印到标准输出的请求以分支描述开始,总结更改并指示可以从何处提取更改。

@HolgerJustmentioned the github gem that does what you want:

@HolgerJust提到了 github gem可以满足您的需求:

sudo gem install gh 
gh pull-request [user] [branch]

Others have mentioned the official hubpackage by github:

其他人提到了hubgithub的官方包:

sudo apt-get install hub

or

或者

brew install hub 

then

然后

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

回答by samccone

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

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

https://npmjs.org/package/pullr

https://npmjs.org/package/pullr

回答by jd_

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

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

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

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!

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

回答by Nishant Nawarkhede

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"'

回答by VonC

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

另外的github/hub,它充当代理的Git,你现在(2020日)有cli/cli

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

请参阅“提升您的命令行体验:GitHub CLI 现在处于测试阶段

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.

创建拉取请求

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

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

cli/cli pr 创建 -- 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.

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



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

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

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 ghto use your preferred editor with gh config set editor [editor].
  • Configure ghto 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.

GitHub CLI 0.7 发布了一些来自我们测试版用户提供的反馈的最强烈要求的增强功能。
自上一个次要版本 0.6 以来,具有三个主要功能:

  • 配置gh为将首选编辑器与gh config set editor [editor].
  • 配置gh为默认使用 SSH gh config set git_protocol ssh
    默认的 Git 协议是 HTTPS。
  • 自动填充来自提交的拉取请求的标题和正文gh pr create --fill

So:

所以:

gh pr create --fill

回答by Andruf

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

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

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

编辑:看起来你可以即时创建问题,所以这个工具是一个很好的解决方案。