git 修改提交历史中的作者信息

2019/01/05 git

修改提交历史中的作者信息

因为一些原因导致提交作者信息出错,需要修正 git rebase -i origin/master # In the rebase list, replace ‘pick’ with ‘edit’ (or ‘e’) for each commit you want to change. Git will rebase, stopping at each commit you marked. Now do this for each commit you marked: git commit –amend –author=”Philip J Fry someone@example.com

2286 down vote accepted Interactive rebase off of a point earlier in the history than the commit you need to modify (git rebase -i ). 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…

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 change the lines for both C and D from pick to edit 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.

How to Fix

先用 git rebase -i HEAD~2 对需要修改的commit使用e选择项 之后输入以下命令 git commit –amend –author=”cool hi@inc.com


Search

    Table of Contents