Git rebase change author?

Git

Git Problem Overview


So I stupidly made 3 commits on a machine that was not configured for git (no author or email) and I want to change those 3 commits (have not been pushed) authors to what they are suppose to be.

I know git commit --amend can change the author, but how can I do it to 3? I know rebase can change the message. Is there a way to change author?

Git Solutions


Solution 1 - Git

You can use interactive rebase. The answer from this post gives you an example: https://stackoverflow.com/questions/3042437/change-commit-author-at-one-specific-commit.

In particular, you can do the following to change one specific commit:

git commit --amend --author="Author Name <[email protected]>" --no-edit

The author asks for changing author at a specific commit, but interactive rebasing can be used to change authors of multiple commits if you edit all commits that you wish to change.

Other potential useful techniques related to interactive rebasing could be found in the Pro Git book http://git-scm.com/book/en/Git-Tools-Rewriting-History, including squashing, redordering, editing messages, etc.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionStevenView Question on Stackoverflow
Solution 1 - GitYangView Answer on Stackoverflow