gpt4 book ai didi

Windows 特定的 Git 配置设置;他们在哪里设置?

转载 作者:IT王子 更新时间:2023-10-29 01:08:31 25 4
gpt4 key购买 nike

我已阅读 Git 文档和 Where do the settings in my Git configuration come from?但我仍然无法理解我的一些设置。

我在 Windows 10 上使用 Git 2.5.3。这是 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

令人烦恼的是前十二个设置我在任何地方都找不到。

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

此外,当我尝试取消设置前十二个设置中的一个时,它没有任何效果:

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

前十二个设置是硬编码的还是特定于平台的?我如何控制它们?

最佳答案

作为this commit解释说,他们只为 Windows 添加了另一个配置位置,甚至在 --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.

所以我相信你可以在 C:\ProgramData\Git\config 中找到那些神秘的设置。


从那个提交我可以看到 git config --system --list 应该已经向你展示了那些设置,但似乎没有 C:\Program Files\Git\mingw64/etc/gitconfig 文件中止了操作,这可能是一个错误。

关于Windows 特定的 Git 配置设置;他们在哪里设置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32847697/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com