似乎您必须与 github.com 交互才能发起拉取请求。是这样吗?
gh pr create --fill
。请参阅[我在下面编辑的答案](stackoverflow.com/a/60197211/6309
UPDATE:hub 命令现在是官方 github 项目,还支持创建 pull requests
原来的:
添加到集线器命令:http://github.com/defunkt/hub 或 github gem:http://github.com/defunkt/github-gem 似乎特别有用
我建议向那些要求它的项目提出问题。 github的家伙反应灵敏。
Git 现在附带一个子命令 'git request-pull' [-p] <start> <url> [<end>]
您可以查看文档 here
您可能会发现这很有用,但 it is not exactly the same as GitHub's feature。
使用 Hub command-line wrapper,您可以将其链接到 git,然后您可以执行 git pull-request
从集线器的手册页:
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.
brew install hub
这似乎是 mac 用户的正确答案。
注意:其中一些答案现在已经过时了。 (2022-01-27)(例如使用 gh Gem。)目前唯一能够做到这一点的工具是 hub 和 gh。
一个男人搜索...
man git | grep pull | grep request
给
git request-pull <start> <url> [<end>]
但是,尽管有名字,但它不是你想要的。根据文档:
生成一个请求,要求您的上游项目将更改拉入他们的树中。打印到标准输出的请求以分支描述开始,总结了更改并指出可以从哪里提取它们。
@HolgerJust 提到了可以满足您需求的 github gem:
sudo gem install gh
gh pull-request [user] [branch]
其他人提到了github的官方hub
包:
sudo apt-get install hub
或者
brew install hub
然后
hub pull-request [-focp] [-b <BASE>] [-h <HEAD>]
git request-pull
行。是的,这是有道理的,但我很惊讶 git 没有像 github 那样通过电子邮件发送拉取请求的命令。毕竟,git config user.email
可供它使用。尤其是使用名为 pull-request
的命令。
github-cli
在 Precise 之后不再可用...我已经 opened a question 要求提供替代方案。
git
客户端创建一个新的私有存储库(项目),其中只有一个 git push -u origin master
和一个新的 origin
url。
除了 github/hub
,其中 acts as a proxy to Git,您现在(2020 年 2 月)还有 cli/cli
:
请参阅“Supercharge your command line experience: GitHub CLI is now in beta”
创建拉取请求 创建一个分支,进行多次提交以修复问题中描述的错误,并使用 gh 创建拉取请求以分享您的贡献。
https://i.stack.imgur.com/X17nW.png
通过使用 GitHub CLI 创建拉取请求,它还会在您还没有分支时自动创建一个分支,它会推送您的分支并创建您的拉取请求以合并您的更改。
2020 年 4 月:“GitHub CLI now supports autofilling pull requests and custom configuration”
GitHub CLI 0.7 已经发布,根据我们的 beta 用户提供的反馈,我们提供了一些要求最高的增强功能。自上一个次要版本 0.6 以来,有三个主要功能: 配置 gh 以使用您的首选编辑器和 gh config set editor [editor]。使用 gh config set git_protocol ssh 将 gh 配置为默认为 SSH。默认的 Git 协议是 HTTPS。使用 gh pr create --fill 从您的提交中自动填充拉取请求的标题和正文。
所以:
gh pr create --fill
我正在使用简单的别名来创建拉取请求,
alias pr='open -n -a "Google Chrome" --args "https://github.com/user/repo/compare/pre-master...nawarkhede:$(git_current_branch)\?expand\=1"'
我最终自己制作了,我发现它在周围的其他解决方案中效果更好。
https://npmjs.org/package/pullr
我最近创建了一个工具,它完全符合您的要求:
https://github.com/jd/git-pull-request
它在单个命令中自动执行所有操作,分叉 repo,推送 PR 等。如果您需要编辑/修复它,它还支持更新 PR!
您可以安装 github official CLI 来创建 PR 并执行其他类型的 things。
建立:
gh auth login
创建公关:
gh pr create
合并:
gh pr merge
auth login
中使用了哪个帐户以及如何确定 PR 是在哪个 repo 中创建的(以及针对哪个帐户)等的更多解释。
gh
将在内部链接这些命令。对于 gh auth login
,系统会询问您是哪个 acc。你想登录..它是交互式的。
我以前用过这个工具——虽然看起来需要先打开一个问题,但如果你使用 github 问题跟踪,它非常有用并且真正简化了工作流程。 git open-pull 然后从您所在或选择的任何分支提交拉取请求。 https://github.com/jehiah/git-open-pull
编辑:看起来你可以即时创建问题,所以这个工具是一个很好的解决方案。
是的。您可以安装 hub CLI 实用程序。
在 MACOS 上:brew install hub
您需要拥有一次 GitHub 令牌才能登录。
User -> Dev settings -> Personal tokens -> Generate
(参见:https://github.com/settings/tokens)
git checkout -b mybranch
hub pull-request -b master -h mybranch
#user: your_user_name
#password: your_git_token
gh pull-request [user] [branch]
。hub
的快速命令:hub pull-request -m "message pull request" -b master -h your_branch
hub merge https://github.com/repo/pull/1