简体   繁体   English

SSH和Git克隆

[英]SSH and Git Clone

Is it possible to ssh to a remote server and trigger a git clone. 是否可以ssh到远程服务器并触发git克隆。 ie I need to ssh to server A, create a folder /tmp/A and clone a repository with all its contents on A. The ssh keys of the remote servers are configured to connect to git. 即我需要ssh到服务器A,创建一个文件夹/ tmp / A并克隆一个存储库,其中所有内容都在A上。远程服务器的ssh密钥配置为连接到git。

ssh root@Server 
git init
git clone gitproject.

This doesn't work. 这行不通。 Any help is appreciated. 任何帮助表示赞赏。 I feel the script steps are run asynchronously and thus the clone fails with .git not found. 我觉得脚本步骤是异步运行的,因此克隆失败,找不到.git。

You said: "I feel the script steps are run asynchronously" , this indicates you are doing all this in a script and therefore your git init and git clone are done local. 您说: "I feel the script steps are run asynchronously" ,这表明您正在脚本中完成所有这些操作,因此git initgit clone是在本地完成的。 You won't actually need git init here. 在这里,您实际上不需要git init

Clone the repository remotely on the server 在服务器上远程克隆存储库

ssh root@server 'git clone gitproject /tmp/A'

to issue the command on the server and have it cloned there. 在服务器上发出命令并将其克隆到那里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM