You need to set up your global core.excludesfile
configuration file to point to this global ignore file.
(您需要设置全局core.excludesfile
文件配置文件以指向此全局忽略文件。)
eg
(例如)
*nix or Windows git bash:
(* nix或Windows git bash:)
git config --global core.excludesfile '~/.gitignore'
Windows cmd:
(Windows cmd:)
git config --global core.excludesfile "%USERPROFILE%.gitignore"
Windows PowerShell:
(Windows PowerShell:)
git config --global core.excludesfile "$Env:USERPROFILE.gitignore"
For Windows it set to the location C:\Users\{myusername}\.gitignore
.
(对于Windows,将其设置为位置C:\Users\{myusername}\.gitignore
。)
You can verify that the config value is correct by doing: (您可以通过执行以下操作来验证配置值是否正确:)
git config --global core.excludesfile
The result should be the expanded path to your user profile's .gitignore
.
(结果应该是用户配置文件.gitignore
的扩展路径。)
Ensure that the value does not contain the unexpanded %USERPROFILE%
string. (确保该值不包含未扩展的%USERPROFILE%
字符串。)
The above commands will only set the location of the ignore file that git will use.
(上面的命令只会设置git将使用的忽略文件的位置。)
The file has to still be manually created in that location and populated with the ignore list.(from muruge 's comment) (该文件仍必须在该位置手动创建并用忽略列表填充。(来自muruge的评论))
You can read about the command at https://help.github.com/articles/ignoring-files/#create-a-global-gitignore
(您可以在https://help.github.com/articles/ignoring-files/#create-a-global-gitignore中阅读有关命令的信息)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…