How to change the commit author for one specific commit?

后端 未结 19 2147
没有蜡笔的小新
没有蜡笔的小新 2020-11-22 05:15

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

19条回答
  •  無奈伤痛
    2020-11-22 05:59

    Steps to rename author name after commit pushed

    1. First type "git log" to get the commit id and more details
    2. git rebase i HEAD~10 (10 is the total commit to display on rebase)

      If you Get anything like below

      fatal: It seems that there is already a rebase-merge directory, and I wonder if you are in the middle of another rebase. If that is the case, please try

      git rebase (--continue | --abort | --skip) If that is not the case, please rm -fr ".git/rebase-merge" and run me again. I am stopping in case you still have something valuable there.

    3. Then type "git rebase --continue" or "git rebase --abort" as per your need

      • now your will rebase window opened, click "i" key from keyboard
      • then you will get list of commits to 10 [because we have passed 10 commit above] Like below

      pick 897fe9e simplify code a little

      pick abb60f9 add new feature

      pick dc18f70 bugfix

    4. Now you need to add below command just below of the commit you want to edit, like below

      pick 897fe9e simplify code a little exec git commit --amend --author 'Author Name ' pick abb60f9 add new feature exec git commit --amend --author 'Author Name ' pick dc18f70 bugfix exec git commit --amend --author 'Author Name '

      1. That's it, now just press ESC, :wq and you are all set

      2. Then git push origin HEAD:BRANCH NAME -f [please take care of -f Force push]

      like git push -f or git push origin HEAD: dev -f

提交回复
热议问题