How can I 'git clone' from another machine?

前端 未结 3 1930
耶瑟儿~
耶瑟儿~ 2020-12-12 15:56

On one machine (IP address 192.168.1.2), I create a Git repository by

$ cd /home/hap/working
$ git init
$ (add some files)
$ git add .
$ git commit -m \'Init         


        
3条回答
  •  粉色の甜心
    2020-12-12 16:38

    You need to use a git+ssh URL to perform the Git cloning:

    git clone git+ssh://hap@192.168.1.2/~/working
    

    To break it down:

    • git+ssh tells Git that you want to use ssh to connect to the Git repository.
    • hap is your username (I assume based on the home directory in your question).
    • 192.168.1.2 is the machine that you want to connect to
    • ~/working is the path to your Git repository on the remote machine (so ~ is your home directory)

    Some other things to note:

    • You need to have a ssh server enabled on the machine with the Git repository
    • You'll need to know the password for the user hap

提交回复
热议问题