相关疑难解决方法(0)

全球Git无视

我想设置Git全局忽略某些文件.

我已经.gitignore在我的用户根目录(/Users/me/)中添加了一个文件,并在其中添加了以下行:

*.tmproj
Run Code Online (Sandbox Code Playgroud)

但它并没有忽略这种类型的文件,任何想法我做错了什么?

git global gitignore

795
推荐指数
9
解决办法
30万
查看次数

解释哪个gitignore规则忽略了我的文件

有没有办法看到为什么一些文件被git忽略(即.gitignore文件中的哪个规则导致文件被忽略)?

想象一下,我有这个(或更复杂的场景,有数百个文件夹和数十个.gitignore文件:

/
-.gitignore
-folder/
    -.gitignore
    -subfolder/
              -.gitignore
              -file.txt
Run Code Online (Sandbox Code Playgroud)

如果我运行git add folder/subfolder/file.txtgit可能会抱怨它被忽略:

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)

git gitignore

291
推荐指数
4
解决办法
4万
查看次数

标签 统计

git ×2

gitignore ×2

global ×1