在一台机器上(IP 地址 192.168.1.2),我创建了一个 Git 仓库
$ cd /home/hap/working
$ git init
$ (add some files)
$ git add .
$ git commit -m 'Initial commit'
我在同一 Wi-Fi 网络上还有另一台机器。我怎样才能从另一台机器上克隆?
最佳答案
您需要使用 git+ssh URL执行 Git 克隆:
git clone git+ssh://hap@192.168.1.2/~/working
分解:
git+ssh
告诉 Git 您想要使用 ssh 连接到 Git 存储库。hap
是您的用户名(我假设基于您问题中的主目录)。192.168.1.2
是您要连接的机器~/working
是远程计算机上 Git 存储库的路径(因此~
是您的主目录)
其他一些注意事项:
- 您需要在具有 Git 存储库的机器上启用 ssh 服务器
- 您需要知道用户
hap
的密码
关于git - 我怎样才能从另一台机器 'git clone'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2808177/