更改提交作者在一个特定的提交 [英] Change commit author at one specific commit
问题描述
我想改变历史中某个特定提交的作者。这不是最后一次提交。
我知道这个问题 - 如何更改git中的提交作者?
但是我我正在考虑某些事情,在那里我通过散列或短散列标识了提交。 解决方案
历史比你需要修改的提交( git rebase -i< earliercommit>
)。在重新分配的提交列表中,将文本从 pick
更改为 edit
,并将其放在您想要的哈希旁边修改。然后当git提示你改变提交时,使用这个:
git commit --amend --author =作者姓名< ; email@address.com>
例如,如果您的提交历史记录为 ABCDEF
与 F
作为 HEAD
,并且您想更改作者 C
和 D
,那么你会......
- 指定
git rebase -i B
(这里是你执行后会看到的一个例子git rebase -i B
命令)
- 如果您需要编辑
A
,请使用git rebase -i --root
- 如果您需要编辑
- 更改
从
挑选
到编辑$ c> 和
D
- 重新开始后,它会首先暂停在
C
- 会
git commit --amend --author =作者姓名< email@address.com>
- 然后
git rebase --continue
- 它会在
处再次暂停D
- 然后您将
git commit --amend --author =作者姓名< email@address.com>
再次
git rebase --continue
$ b $I want to change the author of one specific commit in the history. It's not the last commit.
I know about this question - How do I change the author of a commit in git?
But I am thinking about something, where I identify the commit by hash or short-hash.
解决方案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 frompick
toedit
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>"
For example, if your commit history is
A-B-C-D-E-F
withF
asHEAD
, and you want to change the author ofC
andD
, then you would...- 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
- change the lines for both
C
andD
frompick
toedit
- Once the rebase started, it would first pause at
C
- You would
git commit --amend --author="Author Name <email@address.com>"
- Then
git rebase --continue
- It would pause again at
D
- Then you would
git commit --amend --author="Author Name <email@address.com>"
again git rebase --continue
- The rebase would complete.
这篇关于更改提交作者在一个特定的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!