1

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.

Abimaran Kugathasan
  • 31,165
  • 11
  • 75
  • 105
Karthik
  • 315
  • 1
  • 4
  • 17
  • `This doesn't work` means what exactly? Any Error messages ? Is the dot `.` after `gitproject` intentional ? – Stefan Näwe Aug 13 '14 at 12:37
  • 1
    Maybe simply `ssh root@Server 'git clone Your-URL /tmp/A'` ? – Stefan Näwe Aug 13 '14 at 12:39
  • try to use this way to finish your problem.[reference URL](https://stackoverflow.com/questions/58872037/how-to-use-the-gitbash-to-clone-data-with-ssh-windows-10-environment/58872674#58872674) – Willie Cheng Nov 15 '19 at 08:07

1 Answers1

0

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.

Stephan Rodemeier
  • 717
  • 10
  • 24