Git checkouts fail on Windows with "Filename too long error: unable to create file" errors


アトラシアン コミュニティをご利用ください。


プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。

Server* 製品のサポートは 2024 年 2 月 15 日をもって終了します。Server 製品を利用している場合は、Atlassian Server のサポート終了のお知らせページにて移行オプションをご確認ください。

*Fisheye および Crucible は除く


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


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.


To resolve this issue, we could change the Windows default 260 character limit in the Windows registry or by configuring the core.longpaths workaround in git config.

The solution applies to the Windows system that runs the build and not necessarily only to the Bamboo Server. If you have Bamboo Remote or Elastic Agents running on Windows, please be mindful that the steps below need to be followed on every agent that could possibly run such builds

Starting in Windows 10 (Windows Server 2016), version 1607, MAX_PATH limitations have been removed from common Win32 file and directory functions. However, you must opt-in to the new behaviour. We need to set the Windows default 260 character limit by updating the registry as mentioned here

Go to the registry key Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled (Type: REG_DWORD) must exist and be set to 1.

    New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" `
   -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force

The git configuration setting can be used for Windows versions lower than 2016 and Windows 10.

This setting is disabled by default by git to prevent users from checking out files that Windows Explorer, cmd/bash or some IDE cannot handle.

For Git configuration 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.

Some users have reported the --system parameter does not work, but the --global one does, which would change the command to:

git config --global core.longpaths true

最終更新日 2022 年 4 月 7 日


Powered by Confluence and Scroll Viewport.