All Projects → crazy-max → git-rewrite-author

crazy-max / git-rewrite-author

Licence: MIT license
Rewrite authors / commiters history of a git repository with ease

Programming Languages

go
31211 projects - #10 most used programming language
Dockerfile
14818 projects
HCL
1544 projects

GitHub release Total downloads Build Status Go Report
Become a sponsor Donate Paypal

⚠️ Abandoned project

This project is not maintained anymore and is abandoned. Feel free to fork and make your own changes if needed.

About

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.


Requirements

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

Download

You can download the application matching your platform on the releases page.

Installation

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

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 <[email protected]>
GitHub <[email protected]>
root <root@localhost>

Then you can rewrite a single author/committer:

$ git-rewrite-author rewrite "[email protected]" "John Smith <[email protected]>" --repo /tmp/repo.git

Following authors/committers will be rewritten:
- [email protected] => John Smith <[email protected]

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, [email protected] => John Smith <[email protected]>
- [email protected] => Good Sir <[email protected]>

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", "[email protected]" ],
        "correct_name": "John Smith",
        "correct_mail": "[email protected]"
    },
    {
        "old": [ "[email protected]" ],
        "correct_name": "Good Sir",
        "correct_mail": "[email protected]"
    }
]

Now confirm everything suits to you:

$ git-rewrite-author list --repo /tmp/repo.git
Good Sir <[email protected]>
John Smith <[email protected]>

Review the new Git history for errors and push the corrected history to Git:

$ git push --force --all

Build

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

Contributing

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! 🙏

License

MIT. See LICENSE for more details.
Icon credit to ual Pharm.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].