[英]How do I ignore everything except a couple files in the top-level directory and everything in a few directories with .gitignore
I want to ignore everything except a couple files in the top-level directory and everything in a few directories with .gitignore 我想忽略除顶级目录中的几个文件以及.gitignore的几个目录中的所有内容之外的所有内容
My top level .gitignore is: 我的顶级.gitignore是:
* *
!/app/ !/应用/
!gbase.php !gbase.php
!list-secret-prices.php !列表秘密prices.php
The problem is that I have to put a .gitignore with one entry of: 问题是我必须在.gitignore中添加一个条目:
!* !*
in each of the subdirectories that I want to include for it to work. 在我想要包含的每个子目录中工作。 I don't want to have to put a .gitignore in everyone of the directories that I want included.
我不想将.gitignore放在我想要包含的每个目录中。 I want to handle everything in the top level .gitignore.
我想处理顶级.gitignore中的所有内容。
In your case the following might be more appropriate: 在您的情况下,以下可能更合适:
/*
!app/
!gbase.php
!list-secret-prices.php
The first line ignores all top-level directories and files. 第一行忽略所有顶级目录和文件。 Anything inside the ignored directories will also be ignored by git, even if it's not explicitly specified.
忽略目录中的任何内容也将被git忽略,即使它没有明确指定。
The second line unignores the app
directory. 第二行取消了
app
目录的设置。 It will also cause git to find all its files and subdirectories (recursively), because we never told git to ignore anything below the top-level. 它还会导致git找到它的所有文件和子目录(递归),因为我们从未告诉git忽略顶层以下的任何内容。
I make global exclusions in my gitconfig file ($HOME/.gitconfig) 我在我的gitconfig文件中创建了全局排除项($ HOME / .gitconfig)
[core] excludesfile = /Users/meself/.gitignore [core] excludesfile = /Users/meself/.gitignore
And then write my patterns in ~/.gitignore. 然后在〜/ .gitignore中编写我的模式。
Would this help? 这会有帮助吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.