Git 中作者和提交者的区别? [英] Difference between author and committer in Git?

查看:37
本文介绍了Git 中作者和提交者的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试像这样提交

git commit --author="John Doe <john@doe.com>" -m "<the usual commit message>"

其中 John Doe 是我想以其名义提交的某个用户.

where John Doe is some user in whose name I want to make the commit.

git log中显示正常.但是,当我执行 gitk 时,作者姓名是正确的,但提交者姓名是从我的全局 git 配置设置中选取的(因此设置为我的姓名/电子邮件).

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).

  1. 两者有什么区别(提交者与作者)?

  1. What is the difference between the two (committer vs author)?

我应该将提交者设置为其他用户吗?

Should I be setting the committer as well to the other user?

如果是,怎么做?

推荐答案

原帖问:

两者有什么区别(提交者与作者)?

What is the difference between the two (Committer vs author)?

作者是最初编写代码的人.另一方面,提交者被假定为代表原始作者提交代码的人.这在 Git 中很重要,因为 Git 允许您重写历史记录,或代表他人应用补丁.免费在线Pro Git对此进行了解释像这样:

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 FREE online Pro Git book explains it like this:

您可能想知道 authorcommitter 之间的区别是什么.作者是最初编写补丁的人,而提交者是最后应用补丁的人.因此,如果您向项目发送补丁并且其中一个核心成员应用了该补丁,那么你们双方都会获得荣誉——您是作者,核心成员是提交者.

You may be wondering what the difference is between author and committer. The author is the person who originally wrote the patch, whereas the committer is 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.

原海报问:

我应该将提交者设置为其他用户吗?

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.

这篇关于Git 中作者和提交者的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆