你能从GitHub的命令行发出pull请求吗?

看起来你必须与github.com进行交互来发起一个请求。 这是吗?

看起来像是一个特别有用的东西添加到中心命令: http : //github.com/defunkt/hub或github的gem: http : //github.com/defunkt/github-gem

我build议向那些要求的项目提交一个问题。 Github的家伙相当敏感。

它看起来像现在支持开箱即用命令'git request-pull' [-p] <start> <url> [<end>]

你可以在这里看到文档

使用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. 

一个男人search像…

 man git | grep pull | grep request 

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

但是,尽pipe名字,我不知道这是否你想要的。 Holger的build议似乎奏效:

 ghi pull-request [user] [branch] 

但是你需要先安装github客户端(gh)。 在Ubuntu的这是:

 sudo apt-get install github-cli 

我最终做出了我自己的 ,我发现它可以更好地处理周围的其他解决scheme。

https://npmjs.org/package/pullr

这个答案是现有使用git request-pull命令的另一种方法。 使用这种方法,您不会直接从命令行创build拉取请求,而是从命令行创build拉取请求,这样可以更快,更轻松地通过删除几个步骤在github上创build拉取请求。

我不使用request-pull命令有两个原因:

  1. 我发现寻找其他库的名称,你想要提出拉请求,太花费时间。
  2. 在创build拉取请求之前,可以预览标记格式的文本。

为什么我们不使用github的现有比较function自动创build一个选项卡来比较当前分支与另一个?

我为此创build了一个shell脚本,并创build了一个指向该shell脚本的别名:

 git symbolic-ref HEAD | sed -e "s/^refs\/heads\///" | awk '{printf "https://github.com/USERACCOUNT/REPOSITORY-NAME/compare/%s?expand=1",$1}' | xargs open 

注意:USERACCOUTN和REPOSITORY-NAME需要更改为您的。

让我们把这个脚本放在一个名为create-pull-request.sh的文件中。 那么我们可以通过将这一行添加到.bashrc文件中来创build运行脚本的别名:

 alias makepullrequest="sh PATH-TO-THE-SCRIPT/create-pull-request.sh" 

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

编辑:看起来像你可以在飞行中创build问题,所以这个工具是一个很好的解决scheme。

我最近创build了一个工具,它完全符合你的要求:

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

它在一个单一的命令自动化一切,分叉回购,推PR等。它也支持更新公关,如果你需要编辑/修复它!