我想将 Git 设置为全局忽略某些文件。
我添加了一个.gitignore
文件到我的主目录(/Users/me/
)并且我添加了以下行:
*.tmproj
但它并没有忽略这种类型的文件,知道我做错了什么吗?
您需要设置您的全局core.excludesfile
配置文件指向此全局忽略文件,例如:
*nix 或 Windows git bash:
git config --global core.excludesFile '~/.gitignore'
Windows命令:
git config --global core.excludesFile "%USERPROFILE%\.gitignore"
Windows PowerShell:
git config --global core.excludesFile "$Env:USERPROFILE\.gitignore"
对于 Windows,它设置为位置C:\Users\%username%\.gitignore
。您可以通过执行以下操作来验证配置值是否正确:
git config --global core.excludesFile
结果应该是您的用户配置文件的扩展路径.gitignore
。确保该值不包含未展开的%USERPROFILE%
string.
重要的:上述命令只会设置 git 将使用的忽略文件的位置。该文件仍必须在该位置手动创建并使用忽略列表填充。 (从muruge https://stackoverflow.com/users/265881/muruge的评论)
您可以在以下位置阅读有关该命令的信息https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files#configuring-ignored-files-for-all-repositories-on-your-computer https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files#configuring-ignored-files-for-all-repositories-on-your-computer
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)