Search code examples
gitgitignore

Is there a .gitnotice file?


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?


Solution

  • 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