[英]gitignore everything except specific files
I've been reading on Stack Overflow about using gitignore to ignore everything except specific files. 我一直在阅读Stack Overflow关于使用gitignore忽略除特定文件之外的所有内容。 I've tried a bunch of different suggestions, but I can't get it to work for me.
我尝试了很多不同的建议,但我无法让它为我工作。
Here's what I'm trying to do: I want to exclude everything except one file in my main directory and a couple other files in the subdirectory. 这是我正在尝试做的事情:我想排除除主目录中的一个文件和子目录中的其他几个文件之外的所有内容。 So, I want only these files:
所以,我只想要这些文件:
flightsofideas.rb
/FlightsOfIdeas/svgExportTools.rb
/FlightsOfIdeas/svgExport.rb
My latest version of gitignore is: 我最新版的gitignore是:
*
!flightsofideas.rb
!/FlightsOfIdeas/svgExportTools.rb
!/FlightsOfIdeas/svgExport.rb
But git only includes flightsofideas.rb
, it doesn't get the files in the subdirectory. 但是git只包含
flightsofideas.rb
,它不会获取子目录中的文件。
You should add !*/
not to ignore the directories, or it will not look into the directories to include back files. 你应该添加
!*/
不要忽略目录,否则它不会查看目录以包含返回文件。
Still similar problem as What's the difference between Git ignoring directory and directory/*? 还有类似的问题, Git忽略目录和目录/ *有什么区别? .
。
*
!*/
!/flightsofideas.rb
!/FlightsOfIdeas/svgExportTools.rb
!/FlightsOfIdeas/svgExport.rb
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.