LoginSignup
64
68

More than 1 year has passed since last update.

gitのユーザー名とメールの設定場所でトラブル。

Last updated at Posted at 2014-05-25

gitをインストールした最初の初期設定の後で別の名前やメールに変更したい。

問題

Ubuntu14.04のインストール直後gitの初期データを設定した、しかし後に別の名前とメールを変更する必要に迫られ設定を変更したが、そのデータ設定が反映されなかった。

原因

.zshrc(zshシェルの設定ファイル)に直接書き込んでいた。
(.zshrcをコピペしたため。)
最初gitの設定ファイルは3箇所あると調べあげ、それぞれ設定しなおしてみたがぜんぜん反映されず色々時間を使ってしまった。


git設定ファイルは基本3箇所

  • /etc/gitconfig
    Git でこのファイルの読み書きをするには、
    --system オプションを指定します。

  • ~/.gitconfig
    ホーム直下
    Git でこのファイルの読み書きをするには、
    --global オプションを指定します。

  • .git/config
    リポジトリにある.gitディレクトリ直下
    git config 時にオプションは指定しない。


設定情報はgit config の -l オプションで見る事が出来る。

git config --system -l
git config --global -l
git config -l

設定データはsystem、global、ローカルリポジトリの順番に読まれ、後から読み込んだデータに上書きされる。


git設定データ

名前

masakinihirota

メール

masakinihirota@gmail.com

設定をいろいろ試した時のコマンド。

sudo git config --system user.name "masakinihirota"
sudo git config --system user.email "masakinihirota@gmail.com"
git config --global user.name "masakinihirota"
git config --global user.email "masakinihirota@gmail.com"
git config --local user.name "masakinihirota"
git config --local user.email "masakinihirota@gmail.com"
git config user.name "masakinihirota"
git config user.email "masakinihirota@gmail.com"

確認用のコマンド
sudo git config --system user.name
sudo git config --system user.email
git config --global user.name
git config --global user.email
git config --local user.name
git config --local user.email
git config user.name
git config user.email

.zshrc
GITの個人データ設定
export GIT_COMMITTER_NAME='masakinihirota'
export GIT_AUTHOR_NAME='masakinihirota'
export GIT_AUTHOR_EMAIL='masakinihirota@gmail.com'
export EMAIL='masakinihirota@gmail.com'

64
68
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
64
68