0

For some reason I didn't add my email properly under my github account. And looking at the commit history, for several commits, github shows the username of my local laptop instead of my github username as the author of commit.(As shown in the picture below)

yesterday:
enter image description here

Today I added my email under my github account and pushed a new commit. For the new commit, I now see my github username being the author of commit(as shown in the picture below). However, I'm still seeing my laptop username being the author for previous commits. Is there a way to attribute those previous commits also to my github username instead of my laptop username?

today:
enter image description here

EncryptedWatermelon
  • 4,788
  • 1
  • 12
  • 28
Linzzz
  • 3
  • 1
  • 1
    Short answer : it's not worth the hassle. It can be done, but is there a specific problem posed by this difference in authors? – Romain Valeri Jan 27 '20 at 16:22
  • 1
    Why did you not add your email under your github account - I was not even aware that it was possible. – Michael Nelles Jan 27 '20 at 16:25
  • @RomainValeri not much actually. Just wondering if there is a easy way to unify it. Otherwise it's fine. – Linzzz Jan 27 '20 at 17:42
  • @Nelles I'm using github enterprise and I'm also not so sure about it.. – Linzzz Jan 27 '20 at 17:50
  • Does this answer your question? [How to change the author and committer name and e-mail of multiple commits in Git?](https://stackoverflow.com/questions/750172/how-to-change-the-author-and-committer-name-and-e-mail-of-multiple-commits-in-gi) – Kyle Macey Jan 27 '20 at 18:29

1 Answers1

1

Commits embed the author name into their hash, this can't be changed. You could, however, recreate commits with the same contents, only different authors, through rebasing using filter-branch, but these commits will have different hashes, which means all the next commits (so here if I got it correctly : basically every commit in the repo) will have to change accordingly.

Instead of going into complex rebasing or the even more heavy machinery of git filter-branch, I'd suggest either :

  • consider it a non-problem, until something specific requires the change.

or maybe

  • use a .mailmap for your repo. It'll allow you to map both names to the same label for a number of commands (log being an obvious one)
Romain Valeri
  • 19,645
  • 3
  • 36
  • 61