Git 中作者和提交者的区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18750808/
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
Difference between author and committer in Git?
提问by u1860929
I am trying to make a commit like
我正在尝试做出像
git commit --author="John Doe <[email protected]>" -m "<the usual commit message>"
where John Doe is some user in whose name I want to make the commit.
John Doe 是我想以他的名义提交的某个用户。
It appears all right in git log
. However, when I do a gitk
, the author name is correct, but the committer name is picked from my global git config settings(and is thus set to my name/email).
在git log
. 但是,当我执行 a 时gitk
,作者姓名是正确的,但提交者姓名是从我的全局 git 配置设置中选择的(因此设置为我的姓名/电子邮件)。
Questions
问题
What is the difference between the two (committer vs author)?
Should I be setting the committer as well to the other user?
If yes, how?
两者之间有什么区别(提交者与作者)?
我应该将提交者设置为其他用户吗?
如果是,如何?
采纳答案by u1860929
The original poster asks:
原海报问:
What is the difference between the two (Committer vs author)?
两者之间有什么区别(提交者与作者)?
The author is the person who originally wrote the code. The committer, on the other hand, is assumed to be the person who committed the code on behalf of the original author. This is important in Git because Git allows you to rewrite history, or apply patches on behalf of another person. The FREEonline Pro Gitbookexplains it like this:
作者是最初编写代码的人。另一方面,提交者被假定为代表原作者提交代码的人。这在 Git 中很重要,因为 Git 允许您重写历史记录,或代表他人应用补丁。该免费的在线临Git的书解释它是这样的:
You may be wondering what the difference is between authorand committer. The authoris the person who originally wrote the patch, whereas the committeris the person who last applied the patch. So, if you send in a patch to a project and one of the core members applies the patch, both of you get credit — you as the author and the core member as the committer.
您可能想知道author和committer之间的区别是什么。的作者是谁最初写补丁的人,而提交者是谁最后应用补丁的人。因此,如果您向项目发送补丁并且其中一个核心成员应用了该补丁,那么你们双方都会获得荣誉——您是作者,核心成员是提交者。
The original poster asks:
原海报问:
Should I be setting the committer as well to the other user?
我应该将提交者设置为其他用户吗?
No, if you want to be honest, you should not be setting the committer to the author, unless the author and the committer are indeed the same person.
不,如果你想诚实,你不应该将提交者设置为作者,除非作者和提交者确实是同一个人。
回答by serv-inc
@fxsc 新疆改造中心 proposed to use
@fxsc 新疆改造中心拟使用
GIT_COMMITTER_NAME='a' GIT_COMMITTER_EMAIL='a' git commit --author 'a <a>'
GIT_COMMITTER_NAME='a' GIT_COMMITTER_EMAIL='a' git commit --author 'a <a>'
To avoid repeating the name and email, you can reuse them
为避免重复姓名和电子邮件,您可以重复使用它们
GIT_COMMITTER_NAME='a'; GIT_COMMITTER_EMAIL='a'; git commit --author "$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
which first sets the variables in separate commands, then uses them for the git commit
call (note the double parentheses).
它首先在单独的命令中设置变量,然后将它们用于git commit
调用(注意双括号)。