简体   繁体   English

.gitignore排除目录下的目录,但不排除顶级文件

[英].gitignore exclude directories under directory, but not top-level files

I have a folder populated with both files (mostly archives) and non-specific sub-directories (their expansion) and want to ignore the extracted files. 我有一个同时装有文件(主要是归档文件)和非特定子目录(它们的扩展名)的文件夹,并且想忽略提取的文件。 Files always extract to a sub-directory. 文件始终提取到子目录。

What should I add to my .gitignore ? 我应该在.gitignore中添加什么?

Following this question and its accepted answer , this snippet added to a .gitignore file within the directory in question will do: 此问题及其可接受的答案之后 ,将此片段添加到相关目录中的.gitignore文件中即可:

*
!/*
*~

This ignores everything recursively from this directory, but not the files contained directly in it, except for files ending in ~ (emacs backups). 这将递归地忽略此目录中的所有内容,但不忽略直接包含在其中的文件,除了以〜结尾的文件(emacs备份)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何忽略除顶级目录中的几个文件以及.gitignore的几个目录中的所有内容之外的所有内容 - How do I ignore everything except a couple files in the top-level directory and everything in a few directories with .gitignore 除了顶层以外,如何使用.gitignore排除文件类型? - How to exclude a filetype with .gitignore except in the top-level? .gitignore排除目录中的文件,但不排除某些目录 - .gitignore exclude files in directory but not certain directories 如何制作顶级git来跟踪另一个子目录git下的所有文件 - How to make top-level git to track all the files under another sub-directory git Gitignore:忽略所有 .vscode 目录,但包括顶级 launch.json - Gitignore: Ignore all .vscode directories, but include the top-level launch.json 如何排除除了所有顶级点文件和子目录之外的所有内容? - How can I exclude everything but all top-level dot files and a subdirectory? gitignore无法忽略某些目录下的文件 - gitignore unable to ignore files under certain directories git最佳实践是对顶级目录进行版本控制吗? - Is git best practice to version a top-level directory? 在项目的顶层时,GIT找不到.git目录 - GIT not finding the .git directory when in the top-level of a project 如何gitignore目录中的文件而不是其子目录中的文件? - How to gitignore files in a directory but not files in its sub-directories?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM