Answer the question
In order to leave comments, you need to log in
How to ignore everything but individual files and directories in .gitignore?
The goal is to prevent Git'om from tracking all files in the repository, except for specific files and the contents of subdirectories.
First non-working version:
# Exclude all
*
# Include files
!/foo/bar.xml
# Include directories
!/foo/bar/*
# Exclude all
*
# Track directories, but not the contents
!/foo/
/foo/*
!/foo/bar/
/foo/bar/*
# Include files
!/foo/bar.xml
# Include directories
!/foo/bar/*
Answer the question
In order to leave comments, you need to log in
As already mentioned, you can’t just add a directory to git. No matter how hard you try. If it is vital for you to have some directory under version control, then create in each directory you need (even if it is not empty, but not a single file from it was added to the git repository) a file (it can be empty) with any name - usually add .gitkeep files. And add this file to git.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question