LoginSignup
64
64

More than 5 years have passed since last update.

Git for Windows の設定ファイルの場所

Last updated at Posted at 2017-06-17

Git for Windows の設定ファイルの場所について調べました。
(下記の「system レベルの設定ファイル」の場所に関して、 web 上の情報が古いようだったので、このエントリを書きました。)

動作確認したバージョン・環境は以下です。

  • Git for Windows v2.9.0
  • Windows 10

Git の設定ファイルについて

Git の設定ファイルには、

  • system レベル (当該マシンの全ユーザに関する設定)
  • global レベル (当該ユーザに関する設定)
  • local レベル (特定のディレクトリ (リポジトリ) に関する設定)

の3種類があります1

各設定ファイルの場所

system レベルの設定ファイル

設定ファイルは次の場所にあります。

  • {gitインストール先}\mingw64\etc\gitconfig
  • %PROGRAMDATA%\Git\config (Git for Windows v2.x 以降)

1つめの設定ファイルについては、
git config -l --system で現在の設定内容が見れます。

2つめの設定ファイルについては、
git config -l --file={設定ファイルの場所} で現在の設定内容が見れます。

※1つめの設定ファイルは以前は {gitインストール先}\etc\gitconfig だったらしく、web検索するとその情報ばかり出てきます。が、いつからかは知りませんが、上記のように変わったようです。

なお、公式ドキュメントの以下のページには「Git は、 "MSys root" にある etc/gitconfig を探す」という内容が書いてあります。

Git - First-Time Git Setup

It also still looks for /etc/gitconfig, although it’s relative to the MSys root, which is wherever you decide to install Git on your Windows system when you run the installer.

(↑ここの冒頭の It は Git のこと)
MSYS とか MinGW のことはよく知らないのですが、この "MSys root" が {gitインストール先}\mingw64 ということでしょうか?
でも後半部分からすると、 "MSys root" は {gitインストール先} である、と読める。
ということは、このドキュメントの説明も古いのかもしれません。

※2つめの設定ファイルの場所は、 Windows Vista 以降ならば C:\ProgramData\Git\config です。

Git - First-Time Git Setup

If you are using version 2.x or later of Git for Windows, there is also a system-level config file at C:\Documents and Settings\All Users\Application Data\Git\config on Windows XP, and in C:\ProgramData\Git\config on Windows Vista and newer.

global レベルの設定ファイル

git config -l --global で現在の設定内容が見れます。
設定ファイルは次の場所にあります。

  • C:\Users\{username}\.gitconfig

Git - First-Time Git Setup

On Windows systems, Git looks for the .gitconfig file in the $HOME directory (C:\Users\$USER for most people).

local レベルの設定ファイル

git config -l --local で現在の設定内容が見れます。
設定ファイルは次の場所にあります。

  • 当該リポジトリ直下の .git\config

  1. 「レベル」と書いていますが、これは公式の用語ではなく、私が勝手に使っている言葉です。 

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