Git Windows: Cannot clone/checkout repository paths with spaces
Asked Answered
V

3

11

I am trying to checkout a repository with paths that have spaces. git clone/checkout failed. The following error is returned

fatal: cannot create directory at 'main-path/some-folder-with-space /another-folder': No such file or directory

Resolved by:

  1. Download project zip from github.
  2. Extract the project.
  3. git init
  4. git remote add origin [email protected]:MainRepo/project.git
  5. git fetch --all

Project is now successfully cloned to my windows machine. I can checkout the remote branches without any errors.

Vitric answered 13/3, 2017 at 6:35 Comment(2)
checkout [this] (#19181112) may help youCarpentry
It seems Windows and NTFS doesn't handle spaces at the start or the end of a file or folder name rather well so I would try to avoid this. My attempts to reproduce a problem seems to indicate that Windows itself will silently strip away these spaces when creating the folder, and will silently ignore the spaces when attempting to access the folder from .NET, but not from other tools not based on .NET.Amenra
D
1

Put the address in quotes

git clone "some/folder/with spaces/here.git"
Derbyshire answered 4/1, 2018 at 19:1 Comment(0)
C
0

Assuming you're on the command line, you can just escape spaces with \.

I tried with git clone ../some\ folder\ with\ spaces/.

EDIT: The target folder also contains spaces. No Problem. Can you elaborate on how you tried to clone? Are you using command line or some gui?

Constitutional answered 13/3, 2017 at 7:9 Comment(2)
I am simply cloning a whole project but it is failing because some of the folders inside contain spaces [email protected]:comp/project.gitVitric
It doesn't look like it contains spaces, it looks like it ends with a space.Amenra
V
0

This was resolved by using a lower version of Git Bash (1.9.5) I was using version 2.5.1 when I encountered this issue.

Vitric answered 29/6, 2017 at 1:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.