git -c include.path=<file>
将在<file>
中包含配置。
要自动提取我的非root用户的配置文件,我使用bash
别名:
alias gsudo='sudo git -c "include.path='"${XDG_CONFIG_DIR:-$HOME/.config}/git/config\" -c \"include.path=$HOME/.gitconfig\""
然后我使用gsudo
而不是git
:
检查配置是否确实正在导入:
gsudo config --list --show-origin --includes | less
当然,如果你有任何root-unsafe配置,你应该小心。
或许同时拥有“安全”和“潜在危险”的配置文件是可行的方法。用户的~/.config/git/config
可能是“潜在的危险”,[include]
s是“安全”的root-only配置文件(这是gsudo
别名中唯一使用的配置文件)。