那不是两个作者,而是一个作者和一个提交者。这两个字段有不同的含义。作者是创建内容的人,提交者是提交了内容的人。当您进行普通提交时,您既是作者又是提交者(并且两者都带有相关的电子邮件和时间戳)。
但它们可以在一些关键方面变得不同:
git format-patch
/ git am
- 这对命令允许您将提交转换为补丁,通常通过电子邮件提交,然后由其他人应用。您仍然是作者; 应用它们的人是提交者。这几乎肯定是在github上发生的情况。
git commit --amend
、git rebase
、git filter-branch
- 这些都是基本上是历史重写的变体,范围从单个提交到一些分支历史记录到整个历史记录。它们可以潜在地修改提交者信息 - 特别是,它们总是重写提交者的时间戳。原始作者仍然保持不变(在默认操作模式下),如果作者也是进行重写的人,则他们的名称和电子邮件地址保持不变,但时间戳自然会改变。
man git-format-patch
即可。 - Cascabel一些相关链接:
这并不是多个作者,一个人是作者,另一个人是提交者。
如果您克隆一份,您就可以清楚地看到:
$ git cat-file -p 0a0b150668daa3c6f016
tree 91edcb411b7cd0708c1f5bb05621846146c9425a
parent 6b9ffe3653fe59f035b01ba1f46b5f2650be00ca
author Logan Kearsley <chronosurfer@gmail.com> 1308937685 -0700
committer Felix Geisendo╠Иrfer <felix@debuggable.com> 1309117893 +0200
Slight but definite & consistent performance boost.
类似GitHub和GitLab的Git网络接口
在这种系统中,当合并补丁时,根据存储库设置,作者可能与提交者不同。
由于Git(Hub|Lab)将上游和分叉存储库都放在同一台机器上,因此它可以自动执行您在本地可以执行的任何操作:
Create a merge commit.
Does not generate author != committer.
Keeps the SHA or the new commit intact, and creates a new commit:
* Merge commit (committer == author == project maintainer)
|\
| * Feature commit (committer == author == contributor)
|/
* Old master (random committer and author)
Historically, this was the first available method on GitHub.
Locally, this is done with git merge --no-ff
.
This produces two commits per pull request, and keeps a fork in the git history.
rebase on top of master
While this is not mandatory in principle, and not even done by default locally by git rebase
, GitHub also hacks the commits to set committer == whoever pressed the merge button.
The reason for doing this, is that it gives accountability to the project maintainer.
The git tree now looks like:
* Feature commit (committer == maintainer, author == contributor)
|
* Old master (random committer and author)
which is exactly like that of the git apply
email patches.
目前在GitHub上:
https://help.github.com/articles/about-merge-methods-on-github/