WindowsのGitを使っています。
WindowsとWSLでgitの設定の共通化をするためにincludeを使おうとしたのですが、ホームディレクトリを示すはずの"~"が使えません。
最小限の構成として、~/temp下に
.gitconfig
[include]
path = "~/temp/config2"
config2
[user]
name = "Git Tester"
の2つのファイルを作成しました、
さらに、コマンドラインで以下のコマンドを実行しました。
C: /temp > git init
C: /temp > git config include.path ~/temp/config2
C: /temp > git config --list
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
include.path=~/temp/config2
C: /temp >
結果は上記の通りで、config2内のuser.name
が表示されません。
環境は、
- PowerShell 7.3.4
- git version 2.40.1.windows.1
です。
なんとか、ホームディレクトリからの相対パスでファイルを指定する方法はないでしょうか
user.name=Git Tester
が一覧に出力されています)。マニュアル の記述からすると環境変数HOME
が設定されている必要がありそうです。また、本質からはやや逸れますが、質問文中の~/temp/.gitconfig
ファイルは今回の結果に関与することは無いと思います(.gitcocnfig
という名前のファイルを置くのは ホームディレクトリ であり、また仮にこれをホームディレクトリに置いたとしても global スコープ設定よりコマンドgit config include.path ~/temp/config2
で設定した local スコープのものが優先される)。