Git:忽略文件而不是目录中的子目录 [英] Git: ignore files but not sub-directories in a directory
问题描述
我有一个项目,其中的所有开发都是在某个目录深度完成的,所以我习惯于cd到二级目录并在那里写一些临时文件。这棵树看起来像这样:
$ $ $ $ $ b $ g
dev /
important_stuff /
more_stuff /
自述文件
prod /
important_stuff /
more_stuff /
自述文件
temp_1.txt
test.cc
我想要直接忽略项目中的文件/ - temp_1.txt
和 test.cc
。我可以做到这一点吗?
您可以执行以下操作:
<项目/ * /
项目/ *
! p>这将忽略项目
但是项目
中的所有目录中的所有文件。
I have a project in which all development is done at some directory depth, and so I'm used to cd-ing to a second-level directory and write some temporary files there. The tree looks like this:
repo
.git/
project/
dev/
important_stuff/
more_stuff/
README
prod/
important_stuff/
more_stuff/
README
temp_1.txt
test.cc
I would like to git-ignore exactly files that are directly in project/ - temp_1.txt
and test.cc
in this case. How can I do this?
You can do the following:
project/*
!project/*/
This will ignore all files in project
but unignore all directories in project
.
这篇关于Git:忽略文件而不是目录中的子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!