Git clone ssh with spaces in username, path and different drive

前端 未结 4 777
抹茶落季
抹茶落季 2021-01-21 06:29

I have quantity 3 windows 7 professional machines. Two are setup as development machines (one desktop and one laptop) with Git installed. The third is setup as a file server wit

相关标签:
4条回答
  • 2021-01-21 06:55

    Well, after some time I worked out how to accomplish this.

    git clone "ssh://user name@file-server:/D/path to/repo.git"
    

    Git at the command line is no different from any other command that has spaces in it. Enclose it in quotes... To be more specific, double quotes are less restrictive if using special characters.

    Having a Git repository on a drive other than the default install (C:/) drive does not complicate things.

    The file extension '.git' is required for it to work.

    Is the path case sensitive? Well, when using windows case sensitivity is not a problem. But, for you to be correct and error free (especially between OS), it is always best to reflect the practice of case sensitivity. IE: 'A' is different to 'a'.

    Finally, to reflect a different drive letter to that which Git is installed, place a colon between the computer name and the forward slash. This was the issue tripping me up.

    I hope this information helps other.

    0 讨论(0)
  • 2021-01-21 07:01

    I have tried exactly the same and failed. The issue appears to be that a repo shall be on the c-drive on a windows platform.

    I found no difference using either of

        git clone "ssh://<user name>@<file-server>/<path to repo>"
        git clone "ssh://<user name>@<file-server>/c/<path to repo>" <= note: changed 'd' to 'c'
        git clone "ssh://<user name>@<file-server>/c:/<path to repo>"
    

    To get to a repo on other drives I solved it by using windows links and a folder helper on the c-drive:

        mkdir /<helper folder on c-drive>
        cd /<helper folder on c-drive>
        mklink /J <repo name> <drive letter>:/<path to repo>
    

    Then clone from the helper folder

        git clone "ssh://<user name>@<file-server>/<path to helper folder>/<repo name>"
    
    0 讨论(0)
  • 2021-01-21 07:02

    Got the same problem in http cloning at Azure DevOps Server , Replaced all white spaces with "%20" Ex :-

    git clone http://yourdomain/project%20collection/project1

    try enclosing url with quotes plus spaces with %20 if above solution doesn't works.

    0 讨论(0)
  • 2021-01-21 07:10

    Yes, you have to repo.git in the end.

    For example you can clone a existing git repository like this

    git clone ssh://user@server:/GitRepos/myproject.git

    0 讨论(0)
提交回复
热议问题