3

I've been reading on Stack Overflow about using gitignore to ignore everything except specific files. 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:

*    
!flightsofideas.rb
!/FlightsOfIdeas/svgExportTools.rb
!/FlightsOfIdeas/svgExport.rb

But git only includes flightsofideas.rb, it doesn't get the files in the subdirectory.

poke
  • 369,085
  • 72
  • 557
  • 602

1 Answers1

2

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/*?.

*
!*/
!/flightsofideas.rb
!/FlightsOfIdeas/svgExportTools.rb
!/FlightsOfIdeas/svgExport.rb
Community
  • 1
  • 1
Landys
  • 7,169
  • 3
  • 25
  • 34