LoginSignup
12
4

More than 1 year has passed since last update.

Gitの履歴から名前とメールアドレスを一括変更 (git-filter-repo)

Last updated at Posted at 2020-04-04

タイトルのシチュエーションにおける方法としてgit-filter-branchを使う方法がよく紹介されていますが、git-filter-branchを使用するとgit-filter-repoを代わりに使用するよう警告が出るようになりました。
そこでgit-filter-repoを使う方法を紹介しようと思います。

前提

参照: https://github.com/newren/git-filter-repo#prerequisites

インストール

git-filter-branchはGitに組み込まれた機能ではないので、インストールが必要です。

pipからインストールする場合:

$ pip3 install git-filter-repo

パッケージマネージャからインストールする場合:

$ PACKAGE_TOOL install git-filter-repo

対応しているパッケージマネージャのリスト: https://github.com/newren/git-filter-repo/blob/master/INSTALL.md#installation-via-package-manager

コマンド

まずメールアドレスをマッピングするためのテキストファイルを以下のような形式で作成します。

new_name <new@email.com> <old@email.com>

そしてリポジトリのディレクトリで以下のコマンドを実行します。

git filter-repo --mailmap mailmap

mailmapは上で作成したテキストファイルのパスに置き換えてください。
多くの場合では強制的に修正するために-fをつける必要があるかと思います。

git filter-repo -f --mailmap mailmap

参考: https://stackoverflow.com/questions/58263216/how-to-change-commit-author-for-multiple-commits-using-filter-branch

12
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
4