Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows-specific Git configuration settings; where are they set?

I've read the Git documentation and Where do the settings in my Git configuration come from? and yet I still can't make sense of some of my settings.

I'm on Git 2.5.3 on Windows 10. Here's the output of git config -l:

λ git config -l core.symlinks=false core.autocrlf=true color.diff=auto color.status=auto color.branch=auto color.interactive=true pack.packsizelimit=2g 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 user.name=Ben Collins user.email=#redacted# alias.sm=submodule alias.br=branch alias.co=checkout alias.st=status alias.rebuild=!git rm --cached -r . && git reset --hard core.excludesfile=C:\Users\Benjamin\Documents\gitignore_global.txt core.editor=c:/Users/Benjamin/AppData/Local/atom/bin/atom.cmd core.attributesfile=C:\Users\Benjamin\.gitattributes push.default=simple merge.tool=p4merge mergetool.p4merge.cmd=p4merge.exe "$BASE" "$LOCAL" "$REMOTE" "$MERGED" mergetool.p4merge.path=C:/Program Files/Perforce/p4merge.exe gui.encoding=utf-8 diff.guitool=p4merge difftool.p4merge.path=C:/Program Files/Perforce/p4merge.exe difftool.p4merge.cmd=p4merge.exe "$LOCAL" "$REMOTE" mergetool.keepbackup=false rerere.enabled=true credential.helper=!'C:\Users\Benjamin\AppData\Roaming\GitCredStore\git-credential-winstore.exe' filter.lfs.clean=git lfs clean %f filter.lfs.smudge=git lfs smudge %f filter.lfs.required=true color.diff.whitespace=red reverse 

What's bothersome is that the first twelve settings I cannot find anywhere.

C:\Program Files\Git λ git config --system --list fatal: unable to read config file 'C:\Program Files\Git\mingw64/etc/gitconfig': No such file or directory C:\Program Files\Git λ git config --global --list user.name=Ben Collins user.email=#redacted# alias.sm=submodule alias.br=branch alias.co=checkout alias.st=status alias.rebuild=!git rm --cached -r . && git reset --hard core.excludesfile=C:\Users\Benjamin\Documents\gitignore_global.txt core.editor=c:/Users/Benjamin/AppData/Local/atom/bin/atom.cmd core.attributesfile=C:\Users\Benjamin\.gitattributes push.default=simple merge.tool=p4merge mergetool.p4merge.cmd=p4merge.exe "$BASE" "$LOCAL" "$REMOTE" "$MERGED" mergetool.p4merge.path=C:/Program Files/Perforce/p4merge.exe gui.encoding=utf-8 diff.guitool=p4merge difftool.p4merge.path=C:/Program Files/Perforce/p4merge.exe difftool.p4merge.cmd=p4merge.exe "$LOCAL" "$REMOTE" mergetool.keepbackup=false rerere.enabled=true credential.helper=!'C:\Users\Benjamin\AppData\Roaming\GitCredStore\git-credential-winstore.exe' filter.lfs.clean=git lfs clean %f filter.lfs.smudge=git lfs smudge %f filter.lfs.required=true color.diff.whitespace=red reverse 

Also, when I try to unset one of the first twelve settings, it has no effect:

C:\Users\Benjamin\Projects\blah [master +0 ~1 -0] λ git config --unset core.autocrlf C:\Users\Benjamin\Projects\blah [master +0 ~1 -0] λ git config core.autocrlf true C:\Users\Benjamin\Projects\Saddleback\cm-core [master +0 ~1 -0] λ git config --unset-all core.autocrlf C:\Users\Benjamin\Projects\Saddleback\cm-core [master +0 ~1 -0] λ git config core.autocrlf true 

Are these first twelve settings hardcoded or platform-specific somehow? How do I get control of them?

like image 841
Ben Collins Avatar asked Sep 29 '15 15:09

Ben Collins


People also ask

Where does git store configuration details?

In other words, the file was located in C:\Users\MyLogin\. gitconfig\. gitconfig , instead of on C:\Users\MyLogin\. gitconfig (which is where Git was looking for the files).

How do I see my git settings?

Checking Your Settings If you want to check your configuration settings, you can use the git config --list command to list all the settings Git can find at that point: $ git config --list user.name=John Doe [email protected] color.status=auto color.branch=auto color.interactive=auto color.diff=auto ...

Where do I change git config?

The global git config is simply a text file, so it can be edited with whatever text editor you choose. Open, edit global git config, save and close, and the changes will take effect the next time you issue a git command. It's that easy.


2 Answers

As this commit explains, they've added another config location only for Windows, which is applied even before the --system:

The file /etc/gitconfig can be used to store a system-wide default configuration. On Windows, configuration can also be stored in C:\ProgramData\Git\config; This file will be used also by libgit2-based software.

...

On Windows, as there is no central /etc/ directory, there is yet another config file, intended to contain settings for all Git-related software running on the machine. Consequently, this config file takes an even lower precedence than the $(prefix)/etc/gitconfig file.

So I believe you can find those mystery settings in C:\ProgramData\Git\config.


From that commit I can see that git config --system --list should've shown you those settings, but it seems that the absence of C:\Program Files\Git\mingw64/etc/gitconfig file aborted the operation, which is probably a bug.

like image 197
Roman Avatar answered Sep 29 '22 21:09

Roman


In my version of git there is a --show-origin switch on the list command which gives away where the setting was applied from. I agree that it's confusing that there is no provided switch to access the windows configuration location inside ProgramData.

C:\Users\karlb>git --version git version 2.11.0.windows.3  C:\Users\karlb>git config --list --show-origin file:"C:\\ProgramData/Git/config"       core.symlinks=false file:"C:\\ProgramData/Git/config"       core.autocrlf=true file:"C:\\ProgramData/Git/config"       core.fscache=true file:"C:\\ProgramData/Git/config"       color.diff=auto file:"C:\\ProgramData/Git/config"       color.status=auto file:"C:\\ProgramData/Git/config"       color.branch=auto file:"C:\\ProgramData/Git/config"       color.interactive=true file:"C:\\ProgramData/Git/config"       help.format=html file:"C:\\ProgramData/Git/config"       http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt file:"C:\\ProgramData/Git/config"       diff.astextplain.textconv=astextplain file:"C:\\ProgramData/Git/config"       rebase.autosquash=true file:"C:\\Program Files\\Git\\mingw64/etc/gitconfig"    credential.helper=manager file:"C:\\Program Files\\Git\\mingw64/etc/gitconfig"    difftool.usebuiltin=true file:"C:\\Program Files\\Git\\mingw64/etc/gitconfig"    alias.lol=log --oneline --graph file:"C:\\Program Files\\Git\\mingw64/etc/gitconfig"    alias.last=log -1 HEAD file:C:/Users/karlb/.gitconfig  [email protected] file:C:/Users/karlb/.gitconfig  user.name=Karl Horton 
like image 27
Karl Horton Avatar answered Sep 29 '22 21:09

Karl Horton