Git: ignore folder contents only

I am using the following .gitignore file (global):

.idea
.svn
/media/covers/*
/media/tmp/*
/media/cache/*
/bin
/include
/lib
/local
*.log
*.pot
*.pyc
local_settings.py

So, media/covers, media/tmp, media/cacheI want to ignore all files and folders, but do not do these directories. This .gitignore file ignores media/covers, media/tmp, media/cachedirs, how can I fix it?

TIA!

+5
source share
2 answers

Add the .gitignore file to the directory you want to save. Inside this directory, put

*

Now, when you execute the git status, you will see that the content is not displayed as tracked, but only the .gitignore file. And since the .gitignore file is in the directory, this means that the directory will be tracked, but no other content.

+14
source

Git . , , , , .

- .gitkeep , git. media/covers, media/tmp .. !*.gitkeep/ .gitignore.

+5

All Articles