【git】 AuthorとCommitterの一括置換方法

gitを使っていてログを確認したら期待通りの
AuthorとCommitterになってなくてそれを一括で置換する方法を調べたので
備忘録としてまとめようと思います。

ログを確認

$ git log --pretty=full
commit ab35f3cd84970524f08f830869b07e56844d1e4a (HEAD -> master)
Author: test_name <test_name@test_nameMacBook-Pro.local>
Commit: test_name <test_name@test_nameMacBook-Pro.local>

[add}メインcss

commit 538d38292264a0443f4dd971244a3f147b9976fa
Author: test_name <test_name@test_nameMacBook-Pro.local>
Commit: test_name <test_name@test_nameMacBook-Pro.local>

[add]記事のcss
AuthorとCommitterがtest_name
メールアドレスがローカルPCのものに
になってしまっています。

一括置換

 git filter-branch -f --env-filter   "GIT_AUTHOR_NAME='goodnext'; \
GIT_AUTHOR_EMAIL='y.washizu.1@gmail.com'; \
GIT_COMMITTER_NAME='goodnext'; \
GIT_COMMITTER_EMAIL='y.washizu.1@gmail.com';"   HEAD

上記のコマンドで
AuthorとCommitterがgoodnextに
メールアドレスが自分のメールアドレスに
変更します。

再度ログを確認

$ git log --pretty=full
git log --pretty=full
commit cee70c43258f421725bfcbb7221e95f2aecff6de (HEAD -> master, origin/master)
Author: goodnext <y.washizu.1@gmail.com>
Commit: goodnext <y.washizu.1@gmail.com>

[add}メインcss

commit 43c09588c6a2f5bcce13379623a026d685c49d95
Author: goodnext <y.washizu.1@gmail.com>
Commit: goodnext <y.washizu.1@gmail.com>

[add]記事のcss
無事変更できました。

リモートリポジトリへの反映

$ git push -f
fオプションを付けて強制的にpush

見事書き換わりました。

スクリーンショット 2019-06-22 0.30.41

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です