我如何创建和/或发送一个拉请求到另一个存储库托管在GitHub?
当前回答
我已经启动了一个项目来帮助人们进行他们的第一个GitHub拉请求。你可以在这里通过实践教程来制作你的第一个PR
工作流程简单如
Fork的回购在github 通过点击克隆回购按钮获得克隆url 打开终端,运行git clone <clone url你之前复制的> 为你所做的更改创建一个分支git checkout -b branch-name 做出必要的改变 git Commit提交你的更改 在GitHub上将你的更改推送到你的fork上git Push origin branch-name 去你的GitHub上的分叉看到一个比较和拉请求按钮 点击它并给出必要的细节
其他回答
我已经启动了一个项目来帮助人们进行他们的第一个GitHub拉请求。你可以在这里通过实践教程来制作你的第一个PR
工作流程简单如
Fork的回购在github 通过点击克隆回购按钮获得克隆url 打开终端,运行git clone <clone url你之前复制的> 为你所做的更改创建一个分支git checkout -b branch-name 做出必要的改变 git Commit提交你的更改 在GitHub上将你的更改推送到你的fork上git Push origin branch-name 去你的GitHub上的分叉看到一个比较和拉请求按钮 点击它并给出必要的细节
我遵循蒂姆·彼得森的指示,但我为我的更改创建了一个本地分支。然而,在推动后,我没有看到在GitHub的新分支。解决方案是在push命令中添加-u:
git push -u origin <branch>
(除了官方的“GitHub帮助'使用拉请求'页面”外, 参见“GitHub中的分叉vs.分支”,“GitHub中的起源和上游之间的区别是什么”)
关于pull-requests的几个技巧:
假设你第一次fork了一个回购,下面是你应该在你拥有的fork中做的事情:
create a branch: isolate your modifications in a branch. Don't create a pull request from master, where you could be tempted to accumulate and mix several modifications at once. rebase that branch: even if you already did a pull request from that branch, rebasing it on top of origin/master (making sure your patch is still working) will update the pull request automagically (no need to click on anything) update that branch: if your pull request is rejected, you simply can add new commits, and/or redo your history completely: it will activate your existing pull request again. "focus" that branch: i.e., make its topic "tight", don't modify thousands of class and the all app, only add or fix a well-defined feature, keeping the changes small. delete that branch: once accepted, you can safely delete that branch on your fork (and git remote prune origin). The GitHub GUI will propose for you to delete your branch in your pull-request page.
注意:要编写pull - request本身,请参见“如何编写完美的pull request”(2015年1月,GitHub)
2016年3月:新的PR合并按钮选项:参见“Github在审查评论后的拉请求上从web界面压缩提交?”
回购的维护者可以选择合并——压缩那些PR提交。
Pull请求后
关于最后一点,从2013年4月10日起,“重新设计的合并按钮”,为您删除分支:
合并后删除分支也被简化了。 我们不再使用额外的步骤确认删除,而是在您删除分支时立即删除它,并提供一个方便的链接,以便在您再次需要它时恢复该分支。
这证实了在合并拉取请求后删除分支的最佳实践。
拉请求vs.请求拉
Pull request不是一个官方的“git”术语。 Git使用request-pull(!)命令构建一个合并请求: 它“总结两次提交到标准输出之间的更改,并在生成的摘要中包含给定的URL。” Github在第一天(2008年2月)推出了自己的版本,但在2010年5月重新设计了该功能,并声明: Pull Request =比较视图+问题+提交注释
“资料库”电子注释(原文如此)
<humour>
这(拉请求)甚至没有被GitHub正确定义!
幸运的是,一个真正的商业新闻机构会知道,并且有一个e-note来取代“e-note”:
所以如果你的存储库需要一个电子笔记…问问福克斯商业频道吧。他们知道内情。
</humour>
我写了一个bash程序,它为您完成了所有建立公关分支的工作。如果需要,它会执行分叉,与上游同步,设置上游远程等,你只需要提交你的修改,推送和提交PR。
下面是你如何运行它:
github-make-pr-branch ssh your-github-username orig_repo_user orig_repo_name new-feature
你可以在这里找到这个程序,如果你想了解它是如何工作的,它的存储库还包括手动执行相同过程的逐步指南,以及关于如何使用上游主程序和其他有用的花絮来保持你的特性分支的最新信息。
最简单的GitHub Pull Request来自web界面,不使用git。
Register a GitHub account, login then go to the page in the repository you want to change. Click the pencil icon, search for text near the location, make any edits you want then preview them to confirm. Give the proposed change a description up to 50 characters and optionally an extended description then click the Propose file Change button. If you're reading this you won't have write access to the repository (project folders) so GitHub will create a copy of the repository (actually a branch) in your account. Click the Create pull request button. Give the Pull Request a description and add any comments then click Create pull request button.
推荐文章
- 为什么我需要显式地推一个新分支?
- 如何撤消最后的git添加?
- Rubymine:如何让Git忽略Rubymine创建的.idea文件
- Gitignore二进制文件,没有扩展名
- Git隐藏错误:Git隐藏弹出并最终与合并冲突
- 了解Git和GitHub的基础知识
- 没有。Git目录的Git克隆
- 在GitHub上有一个公共回购的私人分支?
- Git与Mercurial仓库的互操作性
- 忽略git中修改(但未提交)的文件?
- 只用GitHub动作在特定分支上运行作业
- “git restore”命令是什么?“git restore”和“git reset”之间有什么区别?
- Git合并与强制覆盖
- Git拉另一个分支
- 是否有一个链接到GitHub下载文件的最新版本的存储库?