Skip to main content

Git filename error when running the git add command.  The error I'm receiving is

error: open("content/vendor/composer/1ab38258/drupal-core-c84bab7/modules/content_moderation/tests/modules/content_moderation_test_views/config/install/views.view.test_content_moderation_state_filter_base_table_filter_group_or.yml"): Filename too long
error: unable to index file 'content/vendor/composer/1ab38258/drupal-core-c84bab7/modules/content_moderation/tests/modules/content_moderation_test_views/config/install/views.view.test_content_moderation_state_filter_base_table_filter_group_or.yml'
fatal: adding files failed

The consequence of this error means nothing is added to git.  So what's causing this issue?  To begin it handy to know that Git has a limit of 4096 characters for a filename - clearly not issue in this situation.  However, on Windows when Git is compiled with msys.  It uses an older version of the Windows API and there's a limit of 260 characters for a filename.  Therefore, the limitation is on msys rather than Git.  To circumvent this issue, use another Git client on Windows or set core.longpaths to true.

How to set the git long paths: 

git config --system core.longpaths true

Post running this command - running git add workd without issue.