我想设置Git全局忽略某些文件.
我已经.gitignore
在我的用户根目录(/Users/me/
)中添加了一个文件,并在其中添加了以下行:
*.tmproj
Run Code Online (Sandbox Code Playgroud)
但它并没有忽略这种类型的文件,任何想法我做错了什么?
有没有办法看到为什么一些文件被git忽略(即.gitignore
文件中的哪个规则导致文件被忽略)?
想象一下,我有这个(或更复杂的场景,有数百个文件夹和数十个.gitignore
文件:
/
-.gitignore
-folder/
-.gitignore
-subfolder/
-.gitignore
-file.txt
Run Code Online (Sandbox Code Playgroud)
如果我运行git add folder/subfolder/file.txt
git可能会抱怨它被忽略:
The following paths are ignored by one of your .gitignore files:
folder/subfolder/file.txt
Use -f if you really want to add them.
Run Code Online (Sandbox Code Playgroud)
有没有办法知道哪一个可能.gitignore
有规则忽略这个文件,还显示规则?喜欢:
The following paths are ignored by your folder/.gitignore file (line 12: *.txt)
folder/subfolder/file.txt
Use -f if you really want to add them.
Run Code Online (Sandbox Code Playgroud)
要不就:
$ git why-is-ignored folder/subfolder/file.txt
folder/.gitignore:12:*.txt
Run Code Online (Sandbox Code Playgroud)