Interactive rebase off of a point earlier in the history than the commit you need to modify ( git rebase -i <earliercommit>
).
(交互式重新定位在历史记录中比您需要修改的提交更早的一点( 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. (在要重新提交的提交列表中,将文本从pick
更改为您想要修改的哈希旁边的edit
。)
Then when git prompts you to change the commit, use this: (然后,当git提示您更改提交时,请使用以下命令:)
git commit --amend --author="Author Name <[email protected]>"
For example, if your commit history is ABCDEF
with F
as HEAD
, and you want to change the author of C
and D
, then you would...
(例如,如果您的提交历史记录是ABCDEF
且F
为HEAD
,并且您想更改C
和D
的作者,那么您将...)
- Specify
git rebase -i B
( here is an example of what you will see after executing the git rebase -i B
command ) (指定git rebase -i B
( 这是执行git rebase -i B
命令后将看到的示例 ))
- change the lines for both
C
and D
from pick
to edit
(将C
和D
从pick
更改为edit
)
- Once the rebase started, it would first pause at
C
(重新启动基准后,它将首先在C
暂停)
- You would
git commit --amend --author="Author Name <[email protected]>"
(您将git commit --amend --author="Author Name <[email protected]>"
)
- Then
git rebase --continue
(然后git rebase --continue
)
- It would pause again at
D
(它会在D
再次暂停)
- Then you would
git commit --amend --author="Author Name <[email protected]>"
again (然后,您将再次git commit --amend --author="Author Name <[email protected]>"
)
-
git rebase --continue
- The rebase would complete.
(重新设置将完成。)
- Use
git push -f
to update your origin with the updated commits. (使用git push -f
使用更新的提交来更新源。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…