Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
530 views
in Technique[技术] by (71.8m points)

git - can't clone the repository because of the space in the paths

When I trying clone repo, I get an error path in console. The problem only on Windows, on Ubuntu I can clone w/o errors and its ok. I see that spaces in repo between path __tests and /index.js How can I clone it?

remote: Enumerating objects: 573, done.
remote: Counting objects: 100% (573/573), done.
remote: Compressing objects: 100% (223/223), done.
remote: Total 124067 (delta 422), reused 416 (delta 338), pack-reused 123494R
Receiving objects: 100% (124067/124067), 26.59 MiB | 4.13 MiB/s, done.
Resolving deltas: 100% (83046/83046), done.
error: invalid path '/server/__tests__ /index.js'
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.        
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'
question from:https://stackoverflow.com/questions/65924101/cant-clone-the-repository-because-of-the-space-in-the-paths

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This is a limitation of Windows. It does not typically permit paths with trailing spaces, and your repository has a path with one.

That file won't be able to checked out on a regular Windows file system, so you have some options:

  • Rename the directory, commit, and push it to the remote server, if you have access to do so. You can use git mv -f "server/__tests__ " "server/__tests__".
  • Explain the situation to the project maintainer and ask them to rename it.
  • Deal with the fact that this path won't work on Windows.
  • Use Windows Subsystem for Linux or a Linux box to check it out.
  • Convince Microsoft to fix this problem in Windows.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...