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.
Find the commit you want, change pick to e ( edit ), and save and close the file. Git will rewind to that commit, allowing you to either: use git commit --amend to make changes, or.
Update the author details of historical commitsCheck through the commits in the list, and hit ctrl+x , followed by enter to apply the changes.
Using --amend for the Very Last CommitThis effectively replaces the last commit with your "edited" version, correcting the wrong author information.
You can attribute a commit to more than one author by adding one or more Co-authored-by trailers to the commit's message. Co-authored commits are visible on GitHub.
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 protected]>" --no-edit
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...
git rebase -i B
(here is an example of what you will see after executing the git rebase -i B
command) A
, use git rebase -i --root
C
and D
from pick
to edit
:wq
).C
git commit --amend --author="Author Name <[email protected]>"
git rebase --continue
D
git commit --amend --author="Author Name <[email protected]>"
againgit rebase --continue
git push -f
to update your origin with the updated commits.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With