Git: Working with Git on different file systems

Submitted by Peter Majmesku on Mon, 08/29/2016 - 20:09

Git works also on Windows by the Git bash program, which integrates into certain terminal clients, like the one from PhpStorm IDE. To use Git on Windows, you should be aware of a few issues, if you work with other file systems, like the ones from the Unix world (Linux/Mac).

Case insensitive file system

Windows has a case-insensitive filesystem. That means, that the filenames "facebook.jpg" and "Facebook.jpg" are the same file for Windows. If you have such files, you cannot regularly commit. You have to use a special command, to let Git assume this files are unchanged:

git update-index --assume-unchanged FILENAME

Afterwards you can commit and Git will not bother you with that file.

Unix file and folder permissions

Windows does not know about Unix file and folder permissions. Even you have not visibly changes inside your code, Git will mark all files as changed after clone from a Unix file system. To let Windows ignore the file mode use:

git config core.fileMode false

Line endings

Windows has a pair of CR and LF characters to terminate lines. Linux and Mac have a single LF character. To not have all files marked as changed after cloning on a Windows system, use the following setting:

git config --global core.autocrlf true

sed: Another way of fixing wrong line endings on linux

sed is a stream editor which is pre-installed on linux systems like Ubuntu. It can fix line endings by the following command.

sed -i -e 's/\r$//'