3

I have a directory where I want to keep track of only a few files out of many. The .gitignore file would become unnecessarily long compared to a .gitnotice. Is it possible to tell git to ignore everything except the designated files?

Mureinik
  • 297,002
  • 52
  • 306
  • 350
Lotramus
  • 59
  • 1
  • 8

1 Answers1

6

You can use the ! character to negate patterns in .gitignore. So, for example, you could ignore an entire directory other than a couple of specific files:

dir_to_ignore/*
!dir_to_ignore/file_you_want_to_track
!dir_to_ignore/another_file_you_want_to_track
Mureinik
  • 297,002
  • 52
  • 306
  • 350