This project is not maintained anymore and is abandoned. Feel free to fork and make your own changes if needed.
git-rewrite-author is a CLI application written in Go to rewrite one or several authors / committers history of a Git repository with ease. It was inspired by this post on Github.
You must have Git installed on your system and create a fresh, bare clone of your repository:
$ cd /tmp
$ git clone --bare https://github.com/user/repo.git
$ cd /tmp/repo.git
You can download the application matching your platform on the releases page.
Place the executable in your Git repository. It is best to place it in your
PATH
so that you can use it anywhere in your system and also use it with the
Git syntax git rewrite-author
.
Usage: git-rewrite-author <command>
Rewrite authors history of a Git repository with ease. More info:
https://github.com/crazy-max/git-rewrite-author
Flags:
--help Show context-sensitive help.
--version
--repo="." Git repository path.
--log-level="info" Set log level.
--log-caller Add file:line of the caller to log output.
Commands:
config-get
config-set
list
rewrite
rewrite-list
Run "git-rewrite-author <command> --help" for more information on a command.
You probably want to know the list of authors/committers for a repository before rewritting history:
$ git-rewrite-author list --repo /tmp/repo.git
ohcrap <ohcrap@bad.com>
GitHub <noreply@github.com>
root <root@localhost>
Then you can rewrite a single author/committer:
$ git-rewrite-author rewrite "ohcrap@bad.com" "John Smith <john.smith@domain.com>" --repo /tmp/repo.git
Following authors/committers will be rewritten:
- ohcrap@bad.com => John Smith <john.smith@domain.com
Rewrite 4b03c46d8f085f56014e5bee1e5597de86554139 (31/31) (22 seconds passed, remaining 0 predicted)
Ref 'refs/heads/master' was rewritten
Ref 'refs/remotes/origin/master' was rewritten
Ref 'refs/tags/0.15.1-1' was rewritten
Ref 'refs/tags/0.15.2-2' was rewritten
Ref 'refs/tags/0.15.310-3' was rewritten
Ref 'refs/tags/0.16.9-4' was rewritten
Ref 'refs/tags/0.17.13-5' was rewritten
Ref 'refs/tags/0.17.19-6' was rewritten
Ref 'refs/tags/0.18.14-7' was rewritten
Ref 'refs/tags/0.18.23-8' was rewritten
Ref 'refs/tags/0.18.23-9' was rewritten
Ref 'refs/tags/0.18.36-10' was rewritten
Ref 'refs/tags/0.19.48-11' was rewritten
Ref 'refs/tags/0.19.70-12' was rewritten
Or a list of authors/committers:
$ git-rewrite-author rewrite-list ../authors.json --repo /tmp/repo.git
Following authors/committers will be rewritten:
- root@localhost, noreply@github.com => John Smith <john.smith@domain.com>
- ohcrap@bad.com => Good Sir <goodsir@users.noreply.github.com>
Rewrite 4b03c46d8f085f56014e5bee1e5597de86554139 (31/31) (22 seconds passed, remaining 0 predicted)
Ref 'refs/heads/master' was rewritten
Ref 'refs/remotes/origin/master' was rewritten
Ref 'refs/tags/0.15.1-1' was rewritten
Ref 'refs/tags/0.15.2-2' was rewritten
Ref 'refs/tags/0.15.310-3' was rewritten
Ref 'refs/tags/0.16.9-4' was rewritten
Ref 'refs/tags/0.17.13-5' was rewritten
Ref 'refs/tags/0.17.19-6' was rewritten
Ref 'refs/tags/0.18.14-7' was rewritten
Ref 'refs/tags/0.18.23-8' was rewritten
Ref 'refs/tags/0.18.23-9' was rewritten
Ref 'refs/tags/0.18.36-10' was rewritten
Ref 'refs/tags/0.19.48-11' was rewritten
Ref 'refs/tags/0.19.70-12' was rewritten
Here the authors.json
JSON file looks like this:
[
{
"old": [ "root@localhost", "noreply@github.com" ],
"correct_name": "John Smith",
"correct_mail": "john.smith@domain.com"
},
{
"old": [ "ohcrap@bad.com" ],
"correct_name": "Good Sir",
"correct_mail": "goodsir@users.noreply.github.com"
}
]
Now confirm everything suits to you:
$ git-rewrite-author list --repo /tmp/repo.git
Good Sir <goodsir@users.noreply.github.com>
John Smith <john.smith@domain.com>
Review the new Git history for errors and push the corrected history to Git:
$ git push --force --all
git clone https://github.com/crazy-max/git-rewrite-author.git git-rewrite-author
cd git-rewrite-author
# validate (lint, vendors)
docker buildx bake validate
# build binary in ./bin
docker buildx bake
# create artifacts for all supported platforms in ./dist
docker buildx bake artifact-all
Want to contribute? Awesome! The most basic way to show your support is to star the project, or to raise issues. You can also support this project by becoming a sponsor on GitHub or by making a Paypal donation to ensure this journey continues indefinitely!
Thanks again for your support, it is much appreciated! 🙏
MIT. See LICENSE
for more details.
Icon credit to ual Pharm.