Git 中的作者和提交者有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6755824/
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
What is the difference between author and committer in Git?
提问by Chris Bolton
I just came across the following commit on GitHub: https://github.com/felixge/node-formidable/commit/0a0b150668daa3c6f01626d2565b898e5da12392
我刚刚在 GitHub 上遇到以下提交:https: //github.com/felixge/node-formidable/commit/0a0b150668daa3c6f01626d2565b898e5da12392
How does one go about having multiple authors on the same commit like that?
如何让多个作者同时进行这样的提交?
回答by Cascabel
That's not really two authors - that's an author and a committer. The two fields have different meanings. The author is the one who created the content, and the committer is the one who committed it. When you do a normal commit, you are both. (And both come with an associated email and timestamp.)
这不是真正的两个作者——那是一个作者和一个提交者。这两个字段具有不同的含义。作者是创建内容的人,提交者是提交内容的人。当你做一个正常的提交时,你们都是。(两者都带有关联的电子邮件和时间戳。)
But they can become different in a few key ways:
但它们可以在几个关键方面变得不同:
git format-patch
/git am
- this pair lets you turn commits into patches, generally submitted by email, then have someone else apply them. You remain the author; the person who applies them is the committer. This is pretty definitely what happened on github there.git commit --amend
,git rebase
,git filter-branch
- These are all basically variants on history rewriting, ranging from single commit to some history of a branch to the entire history. They can potentially modify the committer information - in particular, they always rewrite the committer timestamp. The original author remains in place (in default modes of operation), and if the author is also the one doing the rewriting, their name and email stay, but the timestamp is naturally different.
git format-patch
/git am
- 这对允许您将提交转换为补丁,通常通过电子邮件提交,然后让其他人应用它们。你仍然是作者;应用它们的人是提交者。这绝对是 github 上发生的事情。git commit --amend
,git rebase
,git filter-branch
- 这些基本上都是历史重写的变体,范围从单个提交到某个分支的某个历史记录到整个历史记录。他们可能会修改提交者信息——特别是,他们总是重写提交者时间戳。原作者保持原位(默认操作模式下),如果作者也是重写者,他们的姓名和电子邮件保持不变,但时间戳自然不同。
回答by peterjmag
There aren't multiple authors associated with that commit (nor is it currently possible to assign multiple authors to a single commit). In this case, gliese1337 was the author, and felixge was the committer. Most likely, this occurred because gliese1337 submitted a pull request which was accepted and then committed by felixhe (the repository owner). That workflow's pretty common on GitHub. This is also helpful for instances when a project maintainer receives a patch via email, so the author of the patch itself still receives credit for the patch, even if he or she doesn't have commit access to the project.
没有多个作者与该提交相关联(目前也不可能将多个作者分配给单个提交)。在这种情况下,gliese1337 是作者,felixge 是提交者。这很可能是因为 gliese1337 提交了一个 pull request,该请求被 felixhe(存储库所有者)接受并提交。该工作流程在 GitHub 上很常见。当项目维护者通过电子邮件收到补丁时,这也很有帮助,因此补丁的作者本身仍然收到补丁的信用,即使他或她没有对项目的提交访问权限。
A couple of related links:
几个相关链接:
Short Git Wiki section on author attribution
A feature request for multiple author functionality in Git core
回答by Ivan Danilov
It is not multiple authors. One is the author and another is commiter.
它不是多个作者。一个是作者,另一个是提交者。
If you'd make a clone you could see it clearly:
如果你做一个克隆,你可以清楚地看到它:
$ git cat-file -p 0a0b150668daa3c6f016
tree 91edcb411b7cd0708c1f5bb05621846146c9425a
parent 6b9ffe3653fe59f035b01ba1f46b5f2650be00ca
author Logan Kearsley <[email protected]> 1308937685 -0700
committer Felix Geisendo╠Иrfer <[email protected]> 1309117893 +0200
Slight but definite & consistent performance boost.