Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git rebase change author? [duplicate]

Tags:

git

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?

like image 550
Steven Avatar asked Apr 25 '13 14:04

Steven


People also ask

Does git rebase change author?

You can use interactive rebase. The answer from this post gives you an example: How to change the commit author for one specific commit?. 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.

How do I change the author and committer name and email of multiple commits in git?

The git commit --amend --reset-author --no-edit command is especially useful if you created commits with the wrong author information, then set the correct author after-the-fact via git config .


1 Answers

You can use interactive rebase. The answer from this post gives you an example: How to change the commit author for 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.

like image 189
Yang Avatar answered Oct 26 '22 04:10

Yang