title: Git renamed files and inodes
body: <p>Consider that we apply the following commands, to a file (<code>hello.txt</code>) tracked under git (in a clean working copy):</p>
  
  <pre><code>echo "hi" &gt;&gt; hello.txt
  mv hello.txt bye.txt
  git rm hello.txt
  git add bye.txt
  git status
  </code></pre>
  
  <p><strong>Result:</strong></p>
  
  <pre><code>On branch master
  Changes to be committed:
    (use "git reset HEAD &lt;file&gt;..." to unstage)
  
      renamed:    hello.txt -&gt; bye.txt
  </code></pre>
  
  <p>So, git knows it is the same file, even though it was renamed.
  I had some vague memory, that git checks inodes to determine that the new file is the same as the old deleted files.
  <a href="https://stackoverflow.com/a/7941544/3398271">This</a> and <a href="https://stackoverflow.com/questions/29822823/how-does-git-know-that-file-was-renamed?noredirect=1&amp;lq=1">this</a> SO answer, though, suggest that git only checks the <strong>contents</strong> of the file, and does not in any way check that it is the same inode. (My conclusion (*): if I did bigger modifications to the file, git would not detect the rename, even though the inode was still the same.)</p>
  
  <p>It seemed to me thus quite obvious, that I was wrong, and git does not check inodes (or any other file-system info at all), just the contents. But then, I found <a href="https://stackoverflow.com/a/4075667/3398271">this other answer</a>, which claims that</p>
  
  <blockquote>
    <p>In addition to the timestamp, it [i.e., git] records the size, inode, and other
    information from lstat to reduce the chance of a false positive. When
    you perform git-status, it simply calls lstat on every file in the
    working tree and compares the metadata in order to quickly determine
    which files are unchanged.</p>
  </blockquote>
  
  <p><strong>I actually have two questions about this:</strong></p>
  
  <ol>
  <li>Is my understanding below correct?</li>
  </ol>
  
  <p><em>Git does rely (also) on inodes to detect if a file was changed, but it does NOT use inodes to detect file renames.</em></p>
  
  <ol start="2">
  <li>Assuming 1. is correct. Why does git not rely on inodes to detect file renames?
  If it did, then we would not have the problem above, marked with (*). (I.e., it would detect the rename, no matter how big the content change.)</li>
  </ol>
  
  <p>(I imagine that the answer is something like "so that the behaviour is the same on system that don't have inodes, e.g. Windows". However, if that's the case, then this "same behaviour" was already broken by relying on inodes for detecting changes.)</p>