git config コマンド
公式サイト:
git-config | Git Documentation [Official]
目次
使い方
設定を一覧で確認する。
$ git config --list
もしくは、--list
の短縮オプション -l
を使う。
$ git config -l
リポジトリの設定を確認する。
$ git config --local --list
ユーザー毎に全リポジトリに適用されるグローバル設定を確認する。
$ git config --global --list
全ユーザーに適用されるシステムの設定を確認する。
$ git config --system --list
どこで設定されているかを含めて一覧で確認する。
$ git config --show-origin --list
参考:
Git の設定を git config で確認/変更 | note.nkmk.me
Git の設定が影響する範囲 (system / global / local) | らくがきちょう
最初の Git の構成 | Pro Git book [公式]
ユーザーの設定
コミット時に使われるユーザー名とメールアドレスの全リポジトリ共通の設定を確認する。
$ git config --global user.name $ git config --global user.email
コミット時に使われるユーザー名とメールアドレスを全リポジトリ共通で設定する。
$ git config --global user.name my_name $ git config --global user.email user@example.com
参考:
とりあえず .gitconfig をいじっとけという話 | ばいばいバイオ
リポジトリ毎にユーザーアカウントを使い分ける
コミット時に使われるユーザー名とメールアドレスのリポジトリにおける設定を確認する。
$ git config --local user.name $ git config --local user.email
コミット時に使われるユーザー名とメールアドレスをリポジトリ内で設定する。
$ git config --local user.name my_name $ git config --local user.email user@example.com
参考:
設定ファイル
システム
インストール済み Git が共通で使用する設定
Linux / Mac の場合
/etc/gitconfig
Windows でシステム領域にインストールした場合
C:\Program Files\Git\etc\gitconfig
Windows でユーザー領域にインストールした場合
C:\Users\[User Name]\AppData\Local\Programs\Git\etc\gitconfig
グローバル
ユーザー毎の設定
~/.gitconfig
ローカル
リポジトリ毎の設定
.git/config
ドキュメント:
Configuration File – git-config | Git Documentation [Official]
参考:
Git for Windows の設定ファイルの場所 – Qiita
Git の conifg ファイルを理解する (system / global / local の違い/場所/編集方法など) | hara-chan.com