Change author information of multiple commits


If I have 200 commits that I have pushed with wrong author information in git config --global and git config --global How can I change these commits afterwards in a command without having to go through every one of each?

All commits are of the same author and some commits are between with a different author. So is it possible to iterate over each commit FROM and TO commits and send a git push --force-with-lease command to update all of these in the history of the master branch?

Any idea?


If they are in a straight line, you could pull it off with a little bit of bash-fu:

git checkout first-commit-to-adjust~ # careful with the pig-tail... it has to be there
git log --pretty=%h --reverse HEAD..last-one-to-adjust | while read commit; do
    git cherry-pick $commit
    # here we need a check for the author name
    if [ "$( git show --summary --pretty=%an --quiet )" == "misnamed fulanito de tal" ]; then
        # yep, it's me
        git commit --amend --no-edit --reset-author

If you want to only set author name/email (not modifying author date), I think you will have to set values for GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL environment variables and then issue the git commit --amend --no-edit command. Concept does not change…. and if you want to control more things, then there are more environment variables at your disposal to play with. Check git help commit.

Answered By – eftshift0

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published