title: Git pre-commit hook + docker = different git status
body: <p>I want to run a script inside a pre-commit git hook. I want that script to run from within a docker image. Example code of this pre-commit hook:</p>
  
  <pre><code># pre-commit hook
  #!/bin/bash
  repo_root=$(git rev-parse --show-toplevel)
  docker run -v ${repo_root}:${repo_root} -w ${repo_root}  &lt;my_docker_image&gt; &lt;path_to_my_script.py&gt;
  </code></pre>
  
  <p><code>my_script.py</code> internally runs <code>git status</code> to determine which files to process in the pre-commit hook.</p>
  
  <p>
  Problem: the output of <code>git status</code> is different in the pre-commit hook than inside the docker container, when I run <code>git commit --all</code>.
  Example:</p>
  
  <pre><code># pre-commit hook
  #!/bin/bash
  git status
  echo "------------------------------------"
  repo_root=$(git rev-parse --show-toplevel)
  docker run -v ${repo_root}:${repo_root} -w ${repo_root} &lt;my_docker_image&gt; git status
  </code></pre>
  
  <p>
  I would expect that by running <code>git commit --all</code>, running <code>git status</code> inside the docker container I could see all the changes staged.</p>
  
  <p>
  However the changes are not staged inside the docker container. The code that I wrote previously prints the following:</p>
  
  <pre><code>Changes to be committed:
    (use "git reset HEAD &lt;file&gt;..." to unstage)
  
      modified:   tools/git-hooks/pre-commit
  ------------------------------------
  Changes not staged for commit:
    (use "git add &lt;file&gt;..." to update what will be committed)
    (use "git checkout -- &lt;file&gt;..." to discard changes in working directory)
  
      modified:   tools/git-hooks/pre-commit
  </code></pre>
  
  <p>In other words: inside docker, <code>git status</code> does NOT detect the <code>--all</code> option; the changes are not staged.</p>
  
  <p>What am I missing?</p>