Git checkouts fail on Windows with "Filename too long error: unable to create file" errors
Platform Notice: Server and Data Center Only - This article only applies to Atlassian products on the server and data center platforms.
Problem
When Bamboo checks out changes from repositories using the Windows Git.exe executable, the task fails and the following appears in the job log
java.lang.RuntimeException : com.atlassian.bamboo.plugins.stash.repository.StashRepositoryException: com.atlassian.bamboo.repository.RepositoryException: Checkout to revision <hash> has failed.command 'C:\Program Files\Git\cmd\git.exe' checkout -f master failed with code 1. Working directory was [<job working directory>].,
stderr: error: unable to create file <filename>: Filename too long error: unable to create file
Cause
According to the msysgit wiki on GitHub and the related fix this error, Filename too long, comes from a Windows API limitation of file paths having 260 characters or fewer.
Resolution
To resolve this issue, please run the following command from GitBash or the Git CMD prompt:
git config --system core.longpaths true
This will allow file paths of 4096 characters.