如何更改一个特定提交的提交作者? [英] How to change the commit author for one specific commit?
问题描述
我想更改历史记录中一项特定提交的作者.这不是最后一次提交.
I want to change the author of one specific commit in the history. It's not the last commit.
我知道这个问题-如何我如何在git中更改提交的作者?
但是我正在考虑一些事情,在这里我用哈希或短哈希来标识提交.
But I am thinking about something, where I identify the commit by hash or short-hash.
推荐答案
交互式基础距历史记录中早于您需要修改的提交(git rebase -i <earliercommit>
)的点.在要重新提交的提交列表中,将要修改的哈希旁边的文本从pick
更改为edit
.然后,当git提示您更改提交时,请使用以下命令:
Interactive rebase off of a point earlier in the history than the commit you need to modify (git rebase -i <earliercommit>
). In the list of commits being rebased, change the text from pick
to edit
next to the hash of the one you want to modify. Then when git prompts you to change the commit, use this:
git commit --amend --author="Author Name <email@address.com>" --no-edit
例如,如果您的提交历史记录是A-B-C-D-E-F
,且F
为HEAD
,并且您想更改C
和D
的作者,那么您将...
For example, if your commit history is A-B-C-D-E-F
with F
as HEAD
, and you want to change the author of C
and D
, then you would...
- 指定
git rebase -i B
(这是执行git rebase -i B
命令后将会看到的示例)- 如果您需要编辑
A
,请使用git rebase -i --root
- 如果您需要编辑
- Specify
git rebase -i B
(here is an example of what you will see after executing thegit rebase -i B
command)- if you need to edit
A
, usegit rebase -i --root
- if you need to edit
这篇关于如何更改一个特定提交的提交作者?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!