I have a directory named img. I want to that directory be exits on the repo, but always it should be empty. I mean just the content of that directory should be untracked.
Here is a simplified of my project:
myproject/ .git/ application/ public/ img/ img1.jpg img2.jpg vendor/ composer.json composer.lock I want to make it like this on repository:
myproject/ .git/ application/ public/ img/ vendor/ composer.json composer.lock How can I do that?
According to some researches, I have to use .gitignore file. But how? Should I make a .gitignore file on the root of project and write this in it?
// .gitignore file public/img/* Or should I make a .gitignore inside img directory? If yes should I write what thing in it?
Ok, now I got a new problem. Let's explain what I want to do exactly. Here is the scenario:
I develop my website locally and push it on the github repository. Then I go in the server and do a git pull. Also there is an img directory that contains all user's avatars. All I'm trying to do is to keep the real-users avatar on img directory. If I put the whole img directory inside .gitignore, then avatars won't be created (because of lack of img directory). If I exclude the content of img directory, then all current user's avatars will be gone when I do a new git pull. Any idea how can I handle such a situation?
.gitkeepfile inimg/, along with a.gitignorethat excludes everything except the keep file. But that ignore file could be in a parent directory, see e.g. github.com/textbook/cyf-library/blob/master/server/… and github.com/textbook/cyf-library/tree/master/server/static where I've done a similar thing.