These days git is one of the most used code tracking software. It uses a file called “.gitignore” to determine the files to be tracked and ignored. If this file is not filled with the correct statements then we might end up losing some of the valuable code while tracking the unwanted files. In this article, I’m going to show how we can un-ignore some subdirectories and files of a directory that is being ignored.
In the above directory structure, the directories highlighted in red color are being ignored while the directories and files highlighted in the green color are being tracked. To achieve this we can use any of the following “.gitignore” files.
ignorethis/* !ignorethis/includethis !ignorethis/*.notignored
ignorethis/* !ignorethis/includethis !ignorethis/file.notignored Here the important thing to note is that we are putting the `ignorethis/*` in both files because if we don't put `/*`. Then any statement for tracking anything inside that directory will not be considered by Git.