如何在 Git 上发送拉取请求
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6235379/
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
How to send pull request on Git
提问by jimy
We have recently migrated to Git from SVN. We have setup a bare repository on one machine in our LAN network and cloned on other machines. Now when anyone do the changes and commits we want that he sends the pull request to the bare repo (by telling or emailing or any other way) after that one will go through the changes and pull it on bare repository (same as it works on GitHub).
我们最近从 SVN 迁移到 Git。我们在 LAN 网络中的一台机器上设置了一个裸存储库,并在其他机器上克隆。现在,当任何人进行更改和提交时,我们希望他将拉取请求发送到裸仓库(通过告诉或发送电子邮件或任何其他方式),之后他将完成更改并将其拉到裸仓库(与它的工作原理相同) GitHub)。
Do we need to install any interface or there is some commands in Git itself?
需要安装什么接口还是Git本身有一些命令?
回答by Greg Hewgill
Both Git (the software) and GitHub (the web service) have a concept called "pull request", and unfortunately they are not exactly the same thing.
Git(软件)和 GitHub(Web 服务)都有一个叫做“拉取请求”的概念,不幸的是它们并不是完全一样的东西。
Native Git
本地 Git
The native Git request-pull
command has a very short manual pagewith the following one-sentence description:
本机 Gitrequest-pull
命令有一个非常简短的手册页,其中包含以下一句话描述:
Summarizes the changes between two commits to the standard output, and includes the given URL in the generated summary.
将两次提交之间的更改汇总到标准输出,并在生成的汇总中包含给定的 URL。
This is a fairly low-level command that generates a short summary of changes that is suitable for posting to a mailing list. Other users can use the URL published in this "pull request" to manually pull changes into their own repository.
这是一个相当低级的命令,它生成适合发布到邮件列表的更改的简短摘要。其他用户可以使用此“拉取请求”中发布的 URL 手动将更改拉取到他们自己的存储库中。
GitHub Pull Requests
GitHub 拉取请求
When using the GitHub web service, a Pull Requestis a full-featured interactive collaboration tool. A GitHub pull request has:
使用GitHub 网络服务时,Pull Request是一个功能齐全的交互式协作工具。GitHub 拉取请求具有:
- a more detailed description of the changes than just the individual commit summaries
- notifications automatically sent to users who have chosen to watch the project
- an online review interface where others can comment on proposed changes
- discussion comments for recording conversations about commits
- central management of pull requests so they won't get lost
- 对更改的更详细描述,而不仅仅是单个提交摘要
- 通知自动发送给选择观看项目的用户
- 在线界面,其他人可以在其中评论提议的更改
- 用于记录有关提交的对话的讨论评论
- 集中管理拉取请求,这样它们就不会丢失
It is worth noting that Linus has his own opinionon the relative utility of these two features.
值得注意的是,Linus对这两个特性的相对效用有自己的看法。
Conclusion
结论
The two "pull request" features described above are similar in spirit but completely different in implementation. In particular, the git request-pull
command cannot be used to create a new Pull Request on GitHub. You have several choices if you want to support "pull request" type functionality:
上面描述的两个“拉取请求”功能在精神上相似但在实现上完全不同。特别是,该git request-pull
命令不能用于在 GitHub 上创建新的 Pull Request。如果您想支持“拉取请求”类型的功能,您有多种选择:
- Use GitHub. This definitely involves the least effort, but if your project is not public you'll have to pay GitHub to host a private repository. Some people might not be comfortable with this choice.
- Use Gerrit. Gerrit is an open-source server program you can download that provides many features similar to those available in GitHub. It is especially well suited to collaborative code reviews.
- Use
git request-pull
and a mailing list. Using this method requires a lot more discipline from your engineers, as it's easy to misplace or mishandle mailing list messages. There is no central accountability associated with this method.
- 使用 GitHub。这绝对需要最少的努力,但如果您的项目不是公开的,您将不得不支付 GitHub 来托管私有存储库。有些人可能对这个选择感到不舒服。
- 使用Gerrit。Gerrit 是一个可以下载的开源服务器程序,它提供了许多与 GitHub 中可用的功能类似的功能。它特别适合协作代码。
- 使用
git request-pull
和邮件列表。使用这种方法需要工程师更多的纪律,因为很容易放错地方或错误处理邮件列表消息。没有与此方法相关的中央问责制。
回答by Jens
The term "pull request" is nota github specific term.
术语“拉取请求”不是github 特定术语。
There is a git request-pull command, you can read more about it here: http://linux.die.net/man/1/git-request-pull
有一个 git request-pull 命令,你可以在这里阅读更多关于它的信息:http: //linux.die.net/man/1/git-request-pull
For some more in depth explanations and save you some googling look at:
有关更深入的解释并为您节省一些谷歌搜索:
- http://git-blame.blogspot.com.ar/2012/01/using-signed-tag-in-pull-requests.html
- http://wiki.koha-community.org/wiki/Sending_a_%22request_to_pull%22
- http://git-blame.blogspot.com.ar/2012/01/using-signed-tag-in-pull-requests.html
- http://wiki.koha-community.org/wiki/Sending_a_%22request_to_pull%22
This is not a new feature BTW.
顺便说一句,这不是一个新功能。
EDIT:This alternative answer was made before the originally accepted answer by @Greg Hewgill was rewritten. I posted it because this is the answer I was looking for, and I think it suited the question which asked about doing pull requests for users not necesarilly using github (Yes, not everyone using git uses github, at least not all the time). Now that the orignal answer was rewritten making this difference explicit I'll leave this answer the way I originally posted it just for the record.
编辑:这个替代答案是在@Greg Hewgill 最初接受的答案被重写之前做出的。我发布它是因为这是我正在寻找的答案,并且我认为它适合询问不需要使用 github 为用户执行拉取请求的问题(是的,不是每个使用 git 的人都使用 github,至少不是所有时间)。既然原始答案已被重写,使这种差异变得明确,我将按照我最初发布的方式保留此答案,仅供记录。
回答by Stein G. Strindhaug
The "git way" of doing this would be that all the developers have their own public bare repository (read acces to all, write acces for the developer himself) on the server as their "origin". And if you like an additional "trunk" (or "stable" or whatever you want to call it) bare repo that some or all developers have write access to. The developers mirror their repo on their public repo, and pull from the other developers. That way you don't have to worry if you push something to your public repo that doesn't work yet. (The developers can just pull from you to a test branch and see if it works.) When you have a stable canonical branch you can push it to the "trunk" repo.
这样做的“git方式”是所有开发人员在服务器上都有自己的公共裸存储库(读取所有人的访问权限,为开发人员自己编写访问权限)作为他们的“来源”。如果你喜欢一个额外的“主干”(或“稳定”或任何你想称之为的)裸仓库,一些或所有开发人员都可以写访问。开发人员将他们的仓库镜像到他们的公共仓库上,并从其他开发人员那里获取。这样您就不必担心是否将某些内容推送到您的公共存储库中还不起作用。(开发人员可以直接从你那里拉到一个测试分支,看看它是否有效。)当你有一个稳定的规范分支时,你可以把它推送到“主干”存储库。