GitHubでpushしたとき、履歴にはアカウント情報が残る.
このとき、Author と Committer が別々に表示され非常に見づらくなることがある.
Author
: オリジナルのコードを書いた人
Committer
: コミットした人
そういう場合にはそれぞれの情報をまとめてPRなどを見やすくしよう.
まず、よく使うアカウントの情報をグローバルに設定する.
以下のコマンドで自動生成され書き込まれる.
git config --global user.name name-of-account
git config --global user.email email@example.com
反映確認.
cat ~/.gitconfig
Git管理されているプロジェクトのディレクトリに移動する.
cd ~/dev/pj-dir
以下のコマンドでそのプロジェクト固有の情報を設定する.
git config --local user.name name-of-2nd-account
git config --local user.email 2nd-email@example.com
git commit --amend
反映確認.
cat .git/config
ローカルの設定をしたあと、各種プロジェクトにおいて適宜Authorの変更も行う.
git commit --amend --author="name-of-2nd-account <2nd-email@example.com>"
git rebase --continue
git log --pretty=full
pushが終わっている場合は -f
付きでpushし直す.
git push -f origin master