LoginSignup
4
2

More than 5 years have passed since last update.

Git の特定の Author と Commiter を変更するシェルスクリプト。

Last updated at Posted at 2017-02-24

スクリプト

#!/bin/sh

if [ $# -ne 3 ]; then
    echo '引数は、変更元コミッターネーム、変更先名前、変更先メールアドレスの順です。' 1>&2
    exit 1
fi

git filter-branch -f --commit-filter "
if [ \"\$GIT_COMMITTER_NAME\" = '$1' ]; then
    GIT_COMMITTER_NAME='$2'
    GIT_COMMITTER_EMAIL='$3'
    GIT_AUTHOR_NAME='$2'
    GIT_AUTHOR_EMAIL='$3'
fi
git commit-tree \"\$@\"
" HEAD

3 行で使えます。
.git ディレクトリが置かれているディレクトリで実行してください。

curl -LSfs -o change_git_committer_and_author.sh https://raw.githubusercontent.com/wsjdev/scripts/master/change_git_committer_and_author.sh
sh change_git_committer_and_author.sh 'bad_name' 'good_name' 'good@email.dayo'
rm change_git_committer_and_author.sh

ここにもあるよ。(GitHub)

効果

第一引数と committer name が一致したコミットの
committer name
author name
を第二引数
committer email
author email
を第三引数に変更します。

4
2
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
4
2