Git on Windows can be tricky and the integration with Intellij IDEA sometimes requires some fine tuning. Some notes follow for future references.
TLDR: My favourite GIT setup on Windows:
git config core.autocrlf true,
git config core.filemode false, explicitly configure line endings for some file types in
There are different ways of getting a command line client on Windows, via the:
- official Git for Windows package
- cygwin bundled packages
- binaries installed along with popular GUI clients (Sourcetree, Github client)
After some testing, I decided to settle with the second option. I use ZSH as my default shell on Windows, so this option felt the more natural to me. Moreover I had had some headaches using the client from the official package (option 1).
The next step is to setup the Intellij IDEA integration in
Version Control > Git in
File -> Settings
Git integration is available if the
Git plugin is installed and enabled.
My definitive setup required some additional minor tweaks to make everything work smoothly (you may not experience the same inconsistencies if you do not mix many different clients as I did).
Fix the changelist
It happened that files were listed as changed in Intellij IDEA, but the diff dialog displayed no difference aganist the current repository version.
In fact, exploring differences from the command line (
git diff), gave a bunch of:
old mode 100755 new mode 100644
Aha! This is related to the unix execution bit mismatch (set by the command line client on Windows but not on the repository). The following setup:
git config core.filemode false
solves the problem.
Mind the EOL?
If your team have users on different operating systems, committing line endings information in the repository can be problematic. Differences in EOL (eg.
CRLF on Windows and
LF on Unix) can bring you back in the days when merging was always a nightmare.
The topic is both interesting and quite controversial. However
git is able to trasparently handle the conversion within the repository leaving your working directory unchanged, but this is not the default option. You must set the following:
git config core.autocrlf true
If you do not set the above option you get a warning whenever Intellij IDEA understands that a commit may introduce EOL problems in the repository. This can be annoying if EOL conversion strategy does not make sense (eg. Windows users only): you can disable the warning in the IDE settings.
If some files must retain a defined EOL, you may always instruct git via the
.gitattributes file, e.g.:
# We dont want CRLF for bash shell scripts *.sh text eol=lf bin/main text eol=lf