.gitignore排除目录中的文件,但不包含某些目录 [英] .gitignore exclude files in directory but not certain directories
问题描述
application / cache / *
application / cache / folder / *
application / cache / folder / onemorefolder / *
这似乎不起作用。当我克隆项目时,没有application / cache
文件夹或application / cache / folder
文件夹,等等...
我想如果缓存文件夹中的文件没有被缓存但是文件夹是这样的,这样文件夹的权限就会被转移并存在。
Git不会跟踪文件夹,只会跟踪文件,所以如果忽略文件夹中的所有内容,Git将无法跟踪任何内容。您可以将 .gitignore
文件添加到每个目录( application / cache
, application / cache /文件夹
,应用程序/缓存/文件夹/ onemorefolder /
)与以下内容:
*
!.gitignore
然后,您可以添加这些目录,并且每个目录中只有 .gitignore
文件将被添加 - 但这意味着目录将被跟踪(即在克隆时创建)。
application/cache/*
application/cache/folder/*
application/cache/folder/onemorefolder/*
This doesn't seem to be working. When I clone the project, there is no "application/cache"
folder or "application/cache/folder"
folder, etc...
I'd like if files in the cache folders weren't cached but folders were, so that the folders permissions transfer and exist.
Git doesn't track folders, only files, so if you ignore everything in a folder, Git won't have anything to track. You can add a .gitignore
file to each directory (application/cache
, application/cache/folder
, application/cache/folder/onemorefolder/
) with the following contents:
*
!.gitignore
Then, you can add those directories, and only the .gitignore
file in each directory will get added -- but this means the directories will now be tracked (i.e., created when cloning).
这篇关于.gitignore排除目录中的文件,但不包含某些目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!