【Git for Windows】シンボリックリンク関係のエラー解消
#結論:プリティーリズムレインボーライブを観てください
Gitのfile, system, globalの設定を弄る必要がありました。
追記:あるいはgit clone時にgit clone -c core.symlinks=true <URL>
をする。
#背景:Windows10にて既存レポジトリを持ってきた際に、シンボリックリンクがなくなって(ディレクトリがファイルになっているし)、修正しようとするとgitでは差分扱いになっちゃうし困ってしまった。
Windows10 : build 16299.431
git version: 2.8.1
#それまでにやったこと:Git for Windowsでシンボリックリンクを扱えるようにする
一通りやりきったものの、それでもシンボリックリンク問題が解消しない。
#手順
そこで、「そもそもgitのconfigはどうなっているんだろう」と確認。
git config --list
core.symlinks=false core.autocrlf=true core.fscache=true color.diff=auto color.status=auto color.branch=auto color.interactive=true help.format=html http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt sendemail.smtpserver=/bin/msmtp.exe diff.astextplain.textconv=astextplain rebase.autosquash=true credential.helper=manager user.name=hogehoge user.email=hogehoge push.default=matching core.autocrlf=false core.symlinks=true core.repositoryformatversion=0 core.filemode=false core.bare=false core.logallrefupdates=true core.symlinks=false core.ignorecase=true core.hidedotfiles=dotGitOnly gitflow.branch.master=master gitflow.branch.develop=develop gitflow.prefix.feature=feature/ gitflow.prefix.bugfix=bugfix/ gitflow.prefix.release=release/ gitflow.prefix.hotfix=hotfix/ gitflow.prefix.support=support/ gitflow.prefix.versiontag= gitflow.path.hooks=C:/Users/hogehoge/workspace/.git/hooks
およそこのようなことが書かれていると思います。
さて、賢い読者様はすでに「シンボリックリンクを有効にしたくて git config --global core.symlinks=true
(※)を実行したのに、どうして1行目からfalseなんじゃい!」とお気づきかもしれません。
(※ちなみにこれでエラーが出たらgit config --global core.symlinks true
を試してください。)
こちらのconfigの出力の並びですが、Git for Windows 2.xのシステムコンフィグファイルは2つある - Qiitaにもある通り、上から順にfile, system..,と並んでいます。これらの設定を有効にする必要があります。
有効にするには、以下のコードを片っ端から打ちます。人によってはいくつか不要になったりlocalも必要になりそうだったりと思いますので、お気をつけて実行してください。
git config --file /c/ProgramData/git config core.symlinks true
git config --system core.symlinks true
はい、これでリポジトリを持ってきてllコマンドで確認するとシンボリックリンクが有効になっていました。ありがとうございました。