msysgit, sourcetree and long paths (>260 chars)

Written by Matej Drolc

Using git on Windows is usually a pleasant experience, but not always. It is not a secret that Windows has problems with file paths which are longer than 260 chars. There are workarounds but they have to be implemented in the application.

With msysgit 1.7.9 installed some very weird things were happening to me.

From the screenshot below, three things can be noticed: msysgit and sourcetree were detecting a lot of files (which had suspicously long paths) as deleted although they were not. And interestingly, when I staged the deletion of such a file in sourcetree, the file reappeared as untracked which is very odd behavior.


I tried the same test with cygwin’s git and there, everything worked as I would have expected it to (no deleted files).

I would have left it at that and used cygwin from that point on, were it not for sourcetree using msysgit under the hood resulting in being broken as well.

Luckily, there is a fix:

  1. Download and install msysgit v. 1.9.0 or higher
  2. enable longpaths with ‘git config core.longpaths true’

After installing msysgit 1.9.0 there is an immediate improvement as now msysgit now warns you about the specific problem with “Filename too long” warnings instead of acting crazy like it was before.


And after you turn on longpaths with

‘git config core.longpaths true’

all the warnings disappear and sourcetree works fine again…

Update When using SourceTree you should also make sure that SourceTree is using the System’s Git and not the embedded one. Tools->Options->Git->”Use System Git” button and point it to the correct git.exe. In my case the path was “C:\Users\username\AppData\Local\Programs\Git\cmd\git.exe”