SSH and Git Clone

痞子三分冷 提交于 2019-12-04 05:22:43

问题


Is it possible to ssh to a remote server and trigger a git clone. 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 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.


回答1:


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. You won't actually need git init here.

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.



来源:https://stackoverflow.com/questions/25285497/ssh-and-git-clone

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!