title: git & Cygwin - trailing whitespace causes "not uptodate"
body: <p>Git on Windows w/ Cygwin is fraught with dangers. However there's one that's really starting to bug me.</p>
  
  <p>It's related to the core.autocrlf=true behaviour. After spending a week trawling the 'net it became clear that the problems you'll encounter are less bad with this set. However, if a file has a line with trailing whitespace on the end, it appears to create a major problem.</p>
  
  <p>The problem is that git thinks the file has local modifications, even though it does not. For example, after a brand-new fresh clone, a 'git status' or 'git diff' will immediately show any such files as modified. A 'git reset --hard' does its thing, but then those files still show as modified. 'git diff' shows the differences as being "an empty line removed, an empty line added".</p>
  
  <p>The problem is, this blocks a git pull!</p>
  
  <pre><code>$ git pull
  Updating 73bcc56..dba6253
  error: Entry 'foo.py' not uptodate. Cannot merge.
  $ git reset --hard
  HEAD is now at 73bcc56 ...
  $ git diff
  diff --git a/foo.py b/foo.py
  index 4cc3854..ccde3f6 100644
  --- a/foo.py
  +++ b/foo.py
  @@ -14,7 +14,7 @@ class TestHelpFunctions(unittest.TestCase):
       def testVersion(self):
           v = sendCommand("version")
           self.assertEqual(len(v), 2)
  -
  +
  </code></pre>
  
  <p>Ok, I think - there's a local change in the way. What if I stash it? Nope - after git stash it still shows this file as locally changed.</p>
  
  <p>Ok, what if I add it? Of course this still blocks a pull:</p>
  
  <pre><code>$ git add foo.py
  $ git pull
  Updating 73bcc56..dba6253
  error: Entry 'foo.py' would be overwritten by merge. Cannot merge.
  </code></pre>
  
  <p>Ok, one last try - let's just commit it and be done with it. Oh great it's conflicted on this file. But the amazing thing is, the file has no conflict markers! Unfortunately 'git pull' now complains that I'm in the middle of a conflicted merge, even though there's no conflict marked.</p>
  
  <p>The fix, I've discovered, is to never commit a file with trailing whitespace before a newline. It just causes git to think the file is modified when it's not, probably due to the DOS-UNIX line ending logic that's obviously broken.</p>
  
  <p>Anyway, I'm not really looking for an answer, because in the end I just nuked the entire thing and recloned. What I'd really like to know is how anyone maintains their sanity while trying to use git with Cygwin.</p>
  
  <p>Don't get me started on 'git add foo/a foo/b FOO/c' when the directory is called "FOO"...</p>