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

前端 未结 3 815
情深已故
情深已故 2020-12-09 02:01

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

相关标签:
3条回答
  • 2020-12-09 02:45

    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  user.email=karl.horton@yahoo.com
    file:C:/Users/karlb/.gitconfig  user.name=Karl Horton
    
    0 讨论(0)
  • 2020-12-09 02:48

    TIL a caveat concerning Git for Widows. I have git version 2.17.1.windows.2.

    I tried to set a global core.attributesfile to override the line-ending attributes for *.sh files (I use WSL, and the present version becomes very unhappy when it tries to run shell scripts with DOS (CRLF) line endings. For Git on the Linux side, the following lines in ~\.gitattributes solve the problem:

    *.sln text eol=crlf
    *.bat text eol=crlf
    *.sh  text eol=cr
    

    But using Git from Windows side (e.g. via Sourcetree GUI), for some repositories, I was still getting CRLF in *.sh files.

    I found that in these repositories, core.autocrlf=true. Setting it to input solves the problem, and Git respects the global gitattributes now.

    0 讨论(0)
  • 2020-12-09 02:51

    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.

    0 讨论(0)
提交回复
热议问题