LoginSignup
1
1

More than 5 years have passed since last update.

git config で設定場所の分からない項目の探し方

Posted at

概要

git で作業していた時 core.autocrlf の値がおかしかったので修正しようと思ったら
system でも global でも local でもない場所に設定されていたのでハマってしまいました。
そんな設定場所の分からない項目を探せる、便利なオプションがありました。

環境

  • Windows 10 Pro
  • git version 2.20.1.windows.1

探し方

結論から言うと --show-origin 1 オプションを使うと、どのファイルから設定されているかが分かります。
git config -l --show-origin を実行すると一覧で取得できます。(内容は長くなるので省きます。)
Windows の場合3箇所以上にファイルが存在していました。

また、個別のファイルの確認コマンドと場所は以下の通りでした。

  1. git config -l -f %PROGRAMDATA%\Git\config
    • 場所: %PROGRAMDATA%\Git\config
  2. git config -l --system
    • Git for Windows を使用している場合
      • 場所: C:\Program Files\Git\mingw64\etc\gitconfig
    • SourceTree を使用している場合
      • 場所: %LOCALAPPDATA%\Atlassian\SourceTree\git_local\mingw32\etc\gitconfig
  3. git config -l --global
    • 場所: %USERPROFILE%\gitconfig
  4. git config -l --local
    • 場所: <Git Repository Path>\.git\config

特に1番はファイルの場所を知っていないと全く分からないです。
ちなみに項目の設定は以下のようにできます。(実行には管理者権限が必要かもしれません。)
git config -f %PROGRAMDATA%\Git\config core.autocrlf false

参考


  1. --show-origin は git 2.8 以降で使用できるようです。 

1
1
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
1
1