3

Let's say you've created a git repo and committed several changes, but then you realize that your global username and e-mail address settings aren't correct, and you need to change all the commits. How can that be done? Is it as easy as changing your global settings, then doing a git rebase --interactive?

Now what if that repo was pushed to GitHub. Luckily, no one else has made changes to that repo or forked it. Is the easiest fix just to nuke the repo on GitHub and then re-create it?

Shaggy Frog
  • 27,575
  • 16
  • 91
  • 128

1 Answers1

3

You can use git filter-branch like (modify "New Name" and "new@email.com"):

git filter-branch --commit-filter 'export GIT_AUTHOR_NAME="New Name"; export GIT_AUTHOR_EMAIL="new@email.com"; git commit-tree "$@"'

If you do not want to do the whole branch you can add a revision range at the end (reva will not be touched):

git filter-branch --commit-filter 'export GIT_AUTHOR_NAME="New Name"; export GIT_AUTHOR_EMAIL="new@email.com"; git commit-tree "$@"' reva..revb
cforbish
  • 8,567
  • 3
  • 28
  • 32