I read from this post which explains that to make git to track a folder there must atleast an empty file:
Currently the design of the Git index (staging area) only permits files
to be listed and nobody competent enough to make the change to allow
empty directories has cared enough about this situation to remedy it.
Directories are added automatically when adding files inside them.
That is, directories never have to be added to the repository,
and are not tracked on their own. You can say "git add <dir>" and it
will add the files in there.
If you really need a directory to exist in checkouts you should
create a file in it.
I have faced some problems because git not tracking empty folders, i am list a few:
Problem1:
I have a apache/log
directory in one of my git repository.
when I pushed it to server and run the website it didn't worked. Where it worked fine in my localsystem. after a lot of research i found out that git push
did n't pushed the empty folder /log
. the serve checked folder log to create logfiles. since folder log
did not exist, it is not possible to automatically create a folder and put these files. That is why the error.
Problem2:
I have lots of branch
. Only one of my particular branch say frontend
have folder caps
.
Sometime one of a folder in the directory my_git_repo/caps/html/home/
will be empty.
branch master
doesn't have folder caps
if i make git checkout master
it will have empty folder ie caps/html/home/tmp
so i want to manually delete the folder caps
sometimes it will create confusion.
usually i solve these problems by putting an empty file(README
) in the folder.
So I would like to make git to track all empty folders. is it possible by editing .git/config
or something?
Any help will be appriciated.:))