2

I have the following folders in a project:

/wwwroot/lib/blue-imp-fileupload
/wwwroot/lib/jquery
/wwwroot/lib/foundation-sites
/wwwroot/lib/font-awesome
/wwwroot/lib/daily/dist

and want to ignore all folders EXCEPT /wwwroot/lib/daily/dist and any sub-folders and files. What would be the gitignore pattern to achieve this?

ChrisP
  • 9,796
  • 21
  • 77
  • 121
  • There are tons of answers for this in this platform. Please use search – Jari Pekkala Mar 01 '17 at 08:56
  • Why is your git root `/` and not `/wwwroot/lib/daily/dist/`? Since you want to ignore everything but this folder I don't see any reason to begin versioning from `/`. – gucce Mar 01 '17 at 15:33

2 Answers2

2

I find the answer here : .gitignore exclude folder but include specific subfolder

In your .gitignore, add:

wwwroot/*
!wwwroot/lib/
wwwroot/lib/*
!wwwroot/lib/daily/
wwwroot/lib/daily/*
!wwwroot/lib/daily/dist/
Community
  • 1
  • 1
Boon
  • 21
  • 3
0

Try this

/wwwroot/lib/blue-imp-fileupload
/wwwroot/lib/jquery
/wwwroot/lib/foundation-sites
/wwwroot/lib/font-awesome

so the /wwwroot/lib/daily/dist will be there. just don't include that path in your .gitignore . I have tested this pattern.

  • 1
    Thanks. Yes, this will work. However, it requires hard coding all the folders to be ignored. Since these folders can change I'd rather have an exclusion for /daily so any new folders would automatically be ignored. I've experimented w/ various !/daily excludes but haven't found the solution yet. – ChrisP Mar 01 '17 at 17:12