Reputation: 6657
I use the following .gitignore file (global):
.idea
.svn
/media/covers/*
/media/tmp/*
/media/cache/*
/bin
/include
/lib
/local
*.log
*.pot
*.pyc
local_settings.py
So in media/covers
, media/tmp
, media/cache
I want to ignore all files and folders, but not this directories themselves. This .gitignore file ignore media/covers
, media/tmp
, media/cache
dirs, how can I fix it?
TIA!
Upvotes: 6
Views: 5759
Reputation: 3284
Git will not add empty directories to its index. I'm guessing that these directories are being excluded because they are empty, not because the match the ignore rules.
One way that people solve this is to create an empty file called .gitkeep
in the directories they would like git to keep. So you could add that file to media/covers
, media/tmp
, etc. Then add !*.gitkeep/
to your .gitignore
file.
Upvotes: 5
Reputation: 150715
Add a .gitignore file to the directory that you want to keep. Within that directory put
*
Now when you do a git status, you will see that the contents are not shown as being tracked, only the .gitignore file. And since the .gitignore file is in the directory, that means that the directory will be tracked, but no other contents.
Upvotes: 14