Reputation: 785
This might have been answered (or maybe its not possible.... which would be odd) - But I haven't been able to find an implicit explanation so was hoping to ask for a little help clearing up the fog.
Heres the concept and problem:
TLDR
: I need to be able to create a repo on my local machine for my server to pull from -
Normally seems that you'd connect your local device to gitHUb >>> Push
to gitHub then >>>> pull to the server
-
But I am wanting to pull directly from my local using SSH to connect to server and git to Pull
////////
I have my local machine
I have a Server (host)
I have connected them via SSH and git has been git init
in both directory
I now want to pull the environment (a Wordpress installed site) from my local
to my server
- In this instance the flow of information must be:
Server PULLS local data
But I cannot figure out how to connect to it? i.e. how to create a hook a point in my local device/directory to then add as a remote in the server.
I hope that makes sense and I'm sure this can be done.
Thanks in advance, Wally
Upvotes: 0
Views: 125
Reputation: 1317
What you want is possible, but unnecessarily complex. You'd have to make sure your local machine is available from the internet via SSH. For this purpose, you'd have to make sure your local machine is addressable by a public IP(v4) address - which depends on whether your ISP gives you a dynamic IP address, or a static one. In case of a dynamic one, you'd have to set up a dynamic DNS service (DynDNS). Also, you need to be able to configure your NAT gateway's portforwarding to forward port 22 to your local machine. Next, you'd have to make a cron job that regularly tries to pull from your local machine's repository.
Usually, you do local changes in your testing environment, commit them and push them. I don't quite get the concept of a server polling for changes to be pulled.
Edit: Making it the other way round works best if you have SSH access to the server where your site is hosted. You can then create a non-bare repository on the server (e.g., if your site is located under /var/www/mysite
you could go into this directory, and initialize it as a repository:
cd /var/www/mysite
git init
Next, you'd want to go to your local machine and add a remote repository to your local git repository:
git remote add origin ssh://user@myhost/var/www/mysite
git push -u origin master
From then on, each push to the origin goes directly into your output directory. The only disadvantage: you have the .git
directory in your root directory.
Upvotes: 1