Git 2.13 conditional config on windows

前端 未结 5 1702
失恋的感觉
失恋的感觉 2020-12-28 15:23

Git version: 2.13.0.windows.1

OS: Windows 7

CLI: Git bash

.gitconfig



        
5条回答
  •  清酒与你
    2020-12-28 15:47

    Your global C:/Users//.gitconfig should have this includeIf:

    [includeIf "gitdir:C:/Users//Documents/webstorm/corporate/"]
        path = .gitconfig-work
    

    with having your work Git repos in C:/Users//Documents/webstorm/corporate and the conditional work configuration should be located at C:/Users//.gitconfig-work.

    That's at least working for me in Window's cmd and Cmder. A git config --show-origin --get user.email should than show you from where a config value is loaded/resolved.

    It also seems like the conditional work configuration is only used when issued from within a Git repository.

    C:\Users\\Documents\webstorm\corporate
    λ git config --show-origin --get user.email
    file:C:/Users//.gitconfig  foo@oss.com
    
    C:\Users\\Documents\webstorm\corporate\some-repo
    λ git config --show-origin --get user.email
    file:C:/Users//.gitconfig-work  foo@company.com
    
    C:\Users\\Documents\webstorm\corporate\some-non-repo-dir
    λ git config --show-origin --get user.email
    file:C:/Users//.gitconfig  foo@oss.com
    

提交回复
热议问题