忽略Git版本控制中的父目录

忽略Git版本控制中的父目录

问题描述:

如何忽略.gitignore中的父目录? 我尝试了这种模式,但似乎不起作用:

How to ignore parent directory in .gitignore? I tried this patterns, but seems they are don't work:

/../*
../
../*

如果想要对.gitignore进行版本控制,则不能.

You can't, if you want your .gitignore to be versioned.

如果已版本化,则意味着父文件夹的元素也已版本化(如果不从索引中删除其所有内容,则不能忽略它).
Kingcrunch

And if it is versioned, that means elements of the parent folder is versioned as well (and cannot be ignored without removing from the index all of its content).
Kingcrunch comments you could still version the .gitignore with a git add -f, but as commented before, this would be quite confusing.

如果最好将.gitignore放在要忽略的文件夹的父文件夹中.
然后那里声明要忽略的文件夹的名称:

If it best to place the .gitignore in the parent folder of the folder you want to ignore.
And there declare the name of the folder you want to ignore:

folder_to_ignore/

(请注意最后一个'/')

(Note the final '/')