Skip to main content

git config

設定値確認

一覧

bash
git config --list --show-origin

特定キーのみ表示

bash
git config --show-origin --get-all credential.helper  # 全部
git config --show-origin --get credential.helper # 最終的に効いている設定だけ

設定コマンドと設定のありか

意味場所設定コマンドメモ
全体(Homebrew)/opt/homebrew/etc/gitconfiggit config --systemcredential.helper=osxkeychain だけ設定されている
ユーザ単位~/.gitconfig or ~/.config/git/configgit config --global
プロジェクト単位/path/to/repo/.git/configgit config --localプロジェクト単位で有効

→ 範囲が狭いほうが優先

いま設定値がどこで設定されているかは git config --list --show-origin で表示

代表的な項目

ユーザ設定

必須項目意味メモ
ouser.nameユーザ名履歴に記録時の変更者情報
ouser.emailメール履歴に記録時の変更者情報
-credential.helper認証時の動作Mac(Homebrew) だとデフォルト osxkeychain

表示系

必須項目意味メモ
-core.quotepathパスのエスケープ有効false に設定すると日本語ファイル名がエスケープされずそのまま見れる
-diff.toolgit difftool 表示時のツールたとえば vimdiff を明示したい場合は指定
-difftool.promptgit difftool で次の差分も見る?のプロンプト表示false で出さない

マージ等の動作

必須項目意味メモ
-pull.rebasegit pull 時のデフォルト動作true: rebase, false: merge。分からない間は消しておくか *1
  • *1: 手で明示する場合は git pull --rebase / git pull --no-rebase

個人設定

必須項目意味メモ
-core.excludesfile.gitignore に常に入れたいもの~/.gitignore_global のようなパスを指定

→ 誤ってコミットしたくないが、プロジェクト共通の .gitignore には含まれていないファイルがある場合などに、ここに設定すれば良さそう

Note: 強制的にコミットしたい場合は git add -f <filename> とすれば良い


以下広告