
Git ignore all files except some files
Sometimes you may need to ignore all of files except only some little files. does gitignore support that ?
The answer is yes. you can use not operator ! like the following.
If we want to ignore all files inside directory_name except __init__.py
# add ignore all in the top of .gitignore file
directory_name/*
# then put the file names you want to be included and put ! operator
# before it.
!__init__.py
3 Comments