DEV Community

Vlad
Vlad

Posted on Edited on

How to change author in pushed commit

What issue I've tried to solve

Some time ago, I set up a new VM to work on a new project, and after a few days of intensive work and multiple pushed commits, I figured out a typo in my email. Luckily, I've made commits to the dedicated feature branch, so I may fix it without disturbing the team

How to fix it

  • Open the terminal (console, command prompt, etc.) and go to the source code folder.
  • Switch to rebase mode
   ➜  git rebase -i HEAD~<N>
Enter fullscreen mode Exit fullscreen mode

where <N> is amount of commits from HEAD.
Or you may specify commit hash or branch

   ➜  git rebase -i 0893420285a5813ddd4a2c86f40054fa4968c9cf
   ➜  git rebase -i master
Enter fullscreen mode Exit fullscreen mode
  • Mark required commits to edit (with e letter)
  • Repeat required times
   ➜  git commit --amend --author="Vladislav Bochenin <vladislav.bochenin@email.com>" --no-edit
   ➜  git rebase --continue
Enter fullscreen mode Exit fullscreen mode
  • Check if everything is ok
   ➜  git log
Enter fullscreen mode Exit fullscreen mode
  • Push changes
   ➜  git push --force
Enter fullscreen mode Exit fullscreen mode

If you find the post helpful, please support me and:
Buy Me A Coffee

Top comments (3)

Collapse
 
evlitvin profile image
Evgenii Vladimirovich Litvin •

Good text.

Collapse
 
komiwave profile image
Komi •

I'm grateful to the author for such an understandable and useful article. Waiting for the new posts, colleague!

Collapse
 
kotikmyrkotik profile image
KoTiKmyrKoTiK •

A pretty good solution. Thanks for the post!