[英]git ignore all folder except a few with a common prefix
I want to ignore all files and folders except five folders that begin with a certain prefix. 我想忽略除以特定前缀开头的五个文件夹以外的所有文件和文件夹。 For example 例如
I want to ignore everything except folders 3 and 4 and their content 我想忽略除文件夹3和4及其内容以外的所有内容
I tried this but it didn't work 我尝试了这个,但是没有用
*
!.gitignore
!/prefix_*
I also tried writing the full names of folder 3 and 4 but it didn't work either. 我还尝试编写文件夹3和4的全名,但是它也不起作用。 git status
tells me that there are no files to commit. git status
告诉我没有文件要提交。
This will ignore all root files and root sub-directories, excluding the .gitignore file and the directories with the prefix prefix_
这将忽略所有根文件和根子目录,但.gitignore文件和带有前缀prefix_
的目录prefix_
/*
/*/
!.gitignore
!/prefix_*
Git should now track the files in the directories with prefix_
and ignore the rest. Git现在应该使用prefix_
跟踪目录中的文件,而忽略其余的文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.