C:\Users\User\Desktop>git clone https://github.com/XXXXXXXXXX.git
Cloning into 'one-piece'...
remote: Counting objects: 5463, done.
remote: Compressing objects: 100% (3600/3600), done.
remote: Total 5463 (delta 1539), reused 5359 (delta 1438), pack-reused 0
Receiving objects: 100% (5463/5463), 5.08 MiB | 1.38 MiB/s, done.
Resolving deltas: 100% (1539/1539), done.
Checking connectivity... done.
warning: unable to access 'hackathon/node_modules/noble/node_modules/bluetooth-hci-socket/node_modules/usb
/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/
node_modules/core-util-is/lib/.gitattributes': Filename too long
fatal: cannot create directory at 'hackathon/node_modules/noble/node_modules/bluetooth-hci-socket/node_mod
ules/usb/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable
-stream/node_modules/process-nextick-args': Filename too long
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry the checkout with 'git checkout -f HEAD'
Asked
Active
Viewed 3.4k times
13

Arjun Chaudhary
- 2,373
- 2
- 19
- 36
-
Please ask questions rather than just post the terminal output with relevant warnings. https://stackoverflow.com/help/how-to-ask – Raj Oct 30 '17 at 21:02
-
Possible duplicate of [Filename too long in Git for Windows](https://stackoverflow.com/questions/22575662/filename-too-long-in-git-for-windows) – iveqy Dec 21 '18 at 06:20
4 Answers
29

svlasov
- 9,923
- 2
- 38
- 39

Bala Krishnan
- 550
- 7
- 11
-
4Be careful when doing this, as it can break other things in Windows. See: https://stackoverflow.com/questions/22575662/filename-too-long-in-git-for-windows – Raj Oct 30 '17 at 20:57
-
I am getting `error: could not lock config file C:/Program Files/Git/etc/gitconfig: Permission denied` – Sazzad Hissain Khan Dec 31 '21 at 09:17
-
2
The following answer worked for me
- Open either cmd or git bash and run it as an administrator
- Give the following command on the cmd or git bash which you ran as an administrator above
git config --system core.longpaths true
- This will allow to access long file names globally
- Now you can clone the repositories without any issue with Filename too long

Niroshan Ratnayake
- 3,433
- 3
- 20
- 18
-
error: could not lock config file C:/Program Files/Git/etc/gitconfig: Permission denied – Sazzad Hissain Khan Dec 31 '21 at 09:16
0
Also check that the repository does not contain a folder called 'con' or 'prn' as these are reserved folders in Windows but are allowed in MacOS.
eg. src/main/kotlin/con/ will break on a Windows machine

Amazing Aidan
- 184
- 6
0
In my case this is how I solved it:
- cd into the project directory and un-stage all staged files if any by running git reset
- undo all changes in the working directory by running git checkout *
After doing the two steps you should be able to see the project files.

Fazil Raza
- 141
- 2
- 6