Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: Ignore only content of the folder

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!

like image 557
Dmitry Belaventsev Avatar asked Sep 20 '12 15:09

Dmitry Belaventsev


1 Answers

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.

like image 56
Abizern Avatar answered Sep 26 '22 20:09

Abizern