0

For the past months I've been working and committing to GitHub without having set the email address in the git config file. Now that I am starting to apply for jobs I am afraid that it might look bad to employers because it seems like I've been slacking all this time. Is there any way to sync the commit credits to the current email so they show up on my profile?

Filip Kubicz
  • 459
  • 1
  • 5
  • 17
Max
  • 754
  • 8
  • 24

1 Answers1

0

NOTE: Please do not rewrite history on shared projects.

But on your personal projects where you are the only contributor, this is perfectly fine.

If you want to change the commit author, you can use this clever tool: https://github.com/jayphelps/git-blame-someone-else and use your new email as <author>.

2nd step is to apply it to multiple commits. This answer comes in handy: Git run shell command for each commit

So overall, you will end up with: git rebase -i --exec "git blame-someone-else <author> <commit>" <first commit in your branch>~

  • to get current commit SHA during rebase, you can insert $(git rev-parse HEAD) instead of <commit>.

  • Instead of <first commit in your branch> you can use $(git rev-list --max-parents=0 HEAD)

Filip Kubicz
  • 459
  • 1
  • 5
  • 17
  • This seems like a great approach. However, I do get the error: Execution failed, when using this command: `git rebase -i --exec "git blame-someone-else 'Max B '" $(git rev-list --max-parents=0 HEAD)`. Any idea what the problem could be? I feel like I might be doing something wrong with the quotation marks. – Max Aug 05 '21 at 15:25
  • This should be `git rebase -i --exec "git blame-someone-else 'Max B ' $(git rev-parse HEAD)" $(git rev-list --max-parents=0 HEAD)` – Filip Kubicz Aug 05 '21 at 23:10
  • You missed the argument. You can first try executing only the command in parentheses `git blame-someone-else 'Max B ' $(git rev-parse HEAD)` - if it works for you, try for more commits. – Filip Kubicz Aug 05 '21 at 23:11
  • Ohh... what a mistake. Thanks a bunch. It isn't yet showing up on my github profile but when use `git log` it shows the correct email now! Fingers crossed it will eventually sync. – Max Aug 06 '21 at 06:52
  • 1
    Correction, I just didn't push the changes. Now it works, thanks for the help! – Max Aug 06 '21 at 10:15