Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (29.3k points)

I have the folder application/ which I add to the .gitignore. Inside the application/ folder is the folder application/language/gr. How can I include this folder? I've tried this

application/

!application/language/gr/

but no luck.

1 Answer

0 votes
by (50.2k points)

If you exclude application/, then everything under it will always be excluded. For this question, you need to use unignore to every parent directory which you want to exclude and include. 

Usually, you end up writing rules for this situation in pairs: which ignores everything in a directory, but not some certain subdirectory.

The pair patterns seem something like this:

!application/

application/*

!application/language/

application/language/*

!application/language/gr/

Note: The trailing /* is significant

Refer: https://git-scm.com/docs/gitignore#_pattern_format

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...