Search code examples
gitbranching-and-merginggit-amend

How to change author name on git branch


I branched my github project to create the static page the other day but messed up with my author name

https://github.com/ronaldsuwandi/le-simplepage/commits/gh-pages

How do I rename the author for the first commit for the branch?

I've tried

But no luck - I'm still really new to git..

EDIT: The answer given by Amber does not work if I want to change the first commit (e.g. if my commit history is A-B-C-D and I would like to change the commit history of B I can do git rebase -i A. But I'm not sure what to do if I want to change commit history of A itself.


Solution

  • git checkout gh-pages
    git reset --hard 02bd
    git commit --amend --author 'Ronald Suwandi <ronald@ronaldsuwandi.com>'
    git cherry-pick 02bd..origin/gh-pages
    git push -f