DEV Community 👩‍💻👨‍💻

Jim Segal
Jim Segal

Posted on

Associating your git commits with a different email

If you have multiple computers or multiple github accounts like I do sometimes you get the commits associated to the wrong account.

I'm currently in the middle of my 31 days of commits challenge and have done this a few times already. Each time I had to look up the set of commands for how to do this, so I figured I would just document it for the next time I need it.

Here we go

Check the git information:

  git log

git log showing incorrect commit authors

Alter multiple commits

Find that commit

Find the commits that you want update and then copy the next commit hash.
git log highlighting commit to rebase to

Start the rebase

  git rebase -i -p <commit_hash> 

If you haven't updated your default editor, you are in vi.

git rebase in vi

Don't be scared. I'll help you through this with the following commands:

  • i to get into insert mode
  • use arrow keys to move around and change the words pick to edit
  • esc to get out of insert mode
  • :wq to save and quit

git rebase final look before saving

Update each individual commit

  git commit --amend --author="Your Name <email@email.com>" --no-edit

  <enter>

  git rebase --continue

  <enter>

Verify things are changed

  git log

git log showing changed commit authors

Celebrate!

Top comments (0)

🌚 Friends don't let friends browse without dark mode.

Just kidding, it's a personal preference. But you can change your theme, font, etc. in your settings.

The more you know. 🌈