Windows git thinks my file is dirty

Do you have dirty files in git? Are you frustrated with how git thinks you’ve soiled a file that you haven’t actually touched? Are you looking for a way to tell git to stop bugging you? Hi I’m Cliff. You’re here because you have dirty files (but you have clean underwear). I’m here because I finally managed to work around a long standing issue where git thought my files were modified under Windows. The problem originates from machines with two different operating systems working on the same project. If you commit files from a *nix system and set the executable bit on then when you clone the project or pull the commit on Windows, git will treat these files as being altered. This is because the executable bit does not exist on Windows so the file appears different on the filesystem. To prevent git from treating these changes as different you should run this command:

git config core.fileMode false

That sets the global config for git to ignore file mode changes (things like read/write/execute). You can set it globally or use it for one off commands like:

git -c core.filemode=false diff