[英]How can I ignore everything but *.cpp files
So I have a file directory that contains many types of files, but I would like to ignore every file except a few and any *.cpp. 因此,我有一个包含许多文件类型的文件目录,但是我想忽略每个文件,除了少数几个* .cpp。 Here is what I have in my .gitignore, but the *.cpp is not being committed. 这是我的.gitignore文件中的内容,但是* .cpp没有提交。
# Ignore Everything
*
# But not .cpp
!*.cpp
!.gitignore
!README.md
You can "un-ignore" directories using !*/
so that it tries adding that directory. 您可以使用!*/
“忽略”目录,以便它尝试添加该目录。 But since git
has no tracking for directories it will still have to find files to add. 但是由于git
无法跟踪目录,因此它仍然必须查找要添加的文件。 Your ignore all *
and don't ignore cpp !*.cpp
will do the trick 您不理会所有*
并且不理会cpp !*.cpp
可以解决问题
Modify your .gitignore
to be: 将您的.gitignore
修改为:
# Ignore Everything
*
# But not .cpp
!*.cpp
# Or directories
!*/
!.gitignore
!README.md
The basic idea is git
tracks files not directories. 基本思想是git
跟踪文件而不是目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.