Git ignore all files except some files

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
AHMED ELKHAYYAT
https://elkhayyat.me

I am a very keen individual that enjoys developing Python Programming Language. I have always loved computers and technology, ever since childhood. A team player who loves to work with other people on innovative projects and to take on challenges as an opportunity to grow as an individual in both a professional and personal capacity.

3 Comments

ehap

thank you for this

    AHMED ELKHAYYAT

    i hope this helped you <3

Leave a Reply

Select your currency
USD United States (US) dollar