如何更改一个特定提交的提交作者? [英] How to change the commit author for one specific commit?

查看:117
本文介绍了如何更改一个特定提交的提交作者?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更改历史记录中一项特定提交的作者.这不是最后一次提交.

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,且FHEAD,并且您想更改CD的作者,那么您将...


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

  1. 指定git rebase -i B(这是执行git rebase -i B命令后将会看到的示例)
    • 如果您需要编辑A,请使用git rebase -i --root
  1. Specify git rebase -i B (here is an example of what you will see after executing the git rebase -i B command)
    • if you need to edit A, use git rebase -i --root

这篇关于如何更改一个特定提交的提交作者?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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