Search code examples
gitwhitespacegit-clone

git clone - Issue with whitspace within URL


I am having issues using git clone with repositories that have whitespace in their names.

For example, my project name in AzureDevOps is: "TestProject - Test" and the URL to clone my git repo is:

git clone --mirror https://[email protected]/organizationname/"TestProject - Test"/_git/"TestProject - Test"

However, if I leave the URL like this, git throws an error saying "repository not found" as it only recognizes the URL until the first whitespace.

If I put the repository name in double or single quotation marks, I get "URL using bad/illegal format or missing URL" error.

I have also tried to escape the whitespace with %20, as suggested by Google:

.../organizationname/TestProject%20-%20Test/_git/TestProject%20-%20Test

But git resolves the URL as /organizationname/TestProject0-0Test/_git/TestProject0-0Test, making it unable to find the project as it doesn't exist with a zero character instead of the whitespace.

Does anyone have an idea how to solve this issue? Thank you in advance.


Solution

  • The %2 being replaced by 0 might be some sort of shell argument replacing, depending on what operating system you are using. Without further information I would suggest trying %%20 to escape the %-sign.