title: How to stop tracking the content of a directory in git?
body: <p>I have a directory named <code>img</code>. 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.</p>
  
  <p>Here is a simplified of my project:</p>
  
  <pre><code>myproject/
      .git/
      application/
      public/
          img/
              img1.jpg
              img2.jpg
      vendor/
      composer.json
      composer.lock
  </code></pre>
  
  <p>I want to make it like this on repository:</p>
  
  <pre><code>myproject/
      .git/
      application/
      public/
          img/
      vendor/
      composer.json
      composer.lock
  </code></pre>
  
  <p>How can I do that?</p>
  
  <hr>
  
  <p>According to some researches, I have to use <code>.gitignore</code> file. But how? Should I make a <code>.gitignore</code> file on the root of project and write this in it?</p>
  
  <pre><code>// .gitignore file
  public/img/*
  </code></pre>
  
  <p>Or should I make a <code>.gitignore</code> inside <code>img</code> directory? If yes should I write what thing in it?</p>
  
  <hr>
  
  <p>Ok, now I got a new problem. Let's explain what I want to do exactly. <strong>Here is the scenario:</strong></p>
  
  <p>I develop my website locally and push it on the github repository. Then I go in the server and do a <code>git pull</code>. Also there is an <code>img</code> directory that contains all user's avatars. All I'm trying to do is to keep the real-users avatar on <code>img</code> directory. If I put the whole <code>img</code> directory inside <code>.gitignore</code>, then avatars won't be created <em>(because of lack of <code>img</code> directory)</em>. If I exclude the content of <code>img</code> 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?</p>