Simply add a remote to your local repo, and push to your remote host.
git remote add origin /url/remotehost/bare_repo
git push --all
For that, your remote host must have a way to be accessed by your local host through one of the supported protocols:
- git daemon
- shared folder
- http(s)
- ssh
And your remote host must have a bare repo, in order to be able to push to it.
On that bare repo, you can declare a post-receive hook which will checkout the received content in your remote host project folder.
The OP chose ssh (ssh://202.XXX.xx.xx:/path/to/repo.git
), but had issue fetching/pushing.
cloning the remote repo is also not working its giving me error
Bad port '' fatal: Could not read from remote repository.
I advised to specify the user which owns the repo on the remote server.
For instance 'git
': git@202.XXX.xx.xx
.
Then to try with and without the ':
':
git@202.XXX.xx.xx:/path/to/repo.git
# or
git@202.XXX.xx.xx/path/to/repo.git
The sshd must be running. The port should be the default one (22).
One can check the sshd logs on the server side (/var/auth/log
).
After all that, the Op reports the setup is working.
The post-receive
hook must be put in the bare repo on the server, and be made executable:
cat > /path/to/bare/repo.git/hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/path/to/live/folder GIT_DIR=/path/to/bare/repo.git git checkout -f
chmod +x /path/to/bare/repo.git/hooks/post-receive