似乎你必须与github.com交互来发起一个拉请求。是这样吗?


当前回答

你可以安装github官方CLI来创建PR和做其他事情。

设置:

Gh auth登录

创建PR:

Gh pr创造

合并:

GH 公关合并

其他回答

你可以安装github官方CLI来创建PR和做其他事情。

设置:

Gh auth登录

创建PR:

Gh pr创造

合并:

GH 公关合并

注意:有些答案现在已经过时了。(2022-01-27) (例如使用gh Gem) 目前唯一能够做到这一点的工具是hub和gh。


一个男人搜索…

man git | grep pull | grep request

给了

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

但是,尽管它的名字,它不是你想要的。根据文件:

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

@HolgerJust提到了github宝石,做你想要的:

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

其他人提到了github的官方中心包:

sudo apt-get install hub

or

brew install hub 

then

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

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

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

使用Hub命令行包装器,您可以将其链接到git,然后就可以执行 git pull请求

从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.

除了github/hub,它作为Git的代理,你现在(2020年2月)有cli/cli:

参见“增强你的命令行体验:GitHub CLI现在处于测试版”

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

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


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

GitHub CLI 0.7发布了我们beta版用户反馈的几个最受欢迎的增强功能。 自上一个小版本0.6以来,有三个主要特性: 将gh配置为使用gh配置集编辑器[editor]的首选编辑器。 配置gh默认为SSH,使用gh config set git_protocol SSH。 Git默认协议为HTTPS。 用gh pr create -fill自动填充你提交的pull请求的标题和正文。

So:

gh pr create --fill