Git で間違った Author 情報で remote repository に commit を push しちゃったとき
はじめに
git log でちゃんと確認したはずが、GitHub へ push したときに committer が間違っていることに気が付きました。
今度からは push 前にローカルで git log --pretty=full
を見て確認するようにします。
コミットの修正
rebase
git rebase <直したい commit の 1つ前の commit hash>
もしくは適当に HEAD から 5 つ遡るでも良いです
git rebase -i HEAD~5
Editor が起動するので当該 commit hash の先頭 (pick
) を edit
へ変更
Editor 上で保存して終了後、commit の修正に入る
git commit --amend --reset-author
git rebase --continue
複数ある場合
以下繰り返す
git commit --amend --reset-author git rebase --continue
Force push
git push -f
PR には force push 後が残ってしまうようですね。。。