更改提交作者在一个特定的提交 [英] Change commit author at one specific commit

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

问题描述

我想改变历史中某个特定提交的作者。这不是最后一次提交。



我知道这个问题 - 如何更改git中的提交作者?



但是我我正在考虑某些事情,在那里我通过散列或短散列标识了提交。 解决方案

历史比你需要修改的提交( git rebase -i< earliercommit> )。在重新分配的提交列表中,将文本从 pick 更改为 edit ,并将其放在您想要的哈希旁边修改。然后当git提示你改变提交时,使用这个:

  git commit --amend --author =作者姓名< ; email@address.com> 






例如,如果您的提交历史记录为 ABCDEF F 作为 HEAD ,并且您想更改作者 C D ,那么你会......


  1. 指定 git rebase -i B 这里是你执行后会看到的一个例子git rebase -i B 命令


    • 如果您需要编辑 A ,请使用 git rebase -i --root


    • 更改挑选编辑 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 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>"
      


      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. 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
      2. change the lines for both C and D from pick to edit
      3. Once the rebase started, it would first pause at C
      4. You would git commit --amend --author="Author Name <email@address.com>"
      5. Then git rebase --continue
      6. It would pause again at D
      7. Then you would git commit --amend --author="Author Name <email@address.com>" again
      8. git rebase --continue
      9. The rebase would complete.

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

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