0

A week ago, I accidentally changed my email settings to public on GitHub. I then made about 20 commits that I discovered weren't showing up on my contribution chart. I have changed my email back to private and set my global git config to the private email again, so my new commits are working fine. However, I've been unable to figure out the git rebase command that I need to retroactively change the name/email on the old commits.

Below is the code that I'm pretty sure I need to run to fix my old commits, but I keep getting "zsh: no such file or directory."

What exactly do I need to put inside for this to work? And do I have to be in the correct repository folder in my terminal?

git rebase -r <some commit before all of your bad commits> \
--exec 'git commit --amend --no-edit --reset-author'
Steven
  • 3
  • 1

1 Answers1

1

If you need to rename the last 20 commits this should work. Put yourself in the root directory of your git repository and then send the command:

git rebase HEAD~20 --exec 'git commit --amend --author="YOURNAME <YOUREMAIL@MAIL.COM>" --no-edit'

Axnyff
  • 9,213
  • 4
  • 33
  • 37
  • This seemed to work as it gave no error and quickly rewrote the 20 commits. However, it is not updated on the GitHub site yet. I assume maybe it will take some time to update? – Steven Aug 07 '22 at 22:19
  • The work you did is only local. You should use `git push` to push it on the remote branch. As you changed history, you will need to do `git push --force`. Are you working alone on that repository ? Otherwise, you could erase the work of other contributors – Axnyff Aug 07 '22 at 22:24
  • 1
    Yes I'm working alone. This worked perfectly! – Steven Aug 07 '22 at 22:31