Posts Tagged 'scp'

How to use git over scp without git on the remote server

This is basically a quick adaptation of this handy tutorial to use scp instead of a usb drive. I find it useful when I have a project I want to track using git across multiple computers, and I don’t want to make it public and use github.

First, make a new directory someplace that will be your local “remote” repository. Essentially, we will use this as the remote repository and use scp to update it when necessary, and then pull from and push to it. Then cd to your working directory, and do

git clone –local –bare . /path/to/remote/repository.git

Then, add it as a remote

git remote add origin file:///path/to/remote/repository.git

Once you’ve done this, you can simply do a git push to push to this repository. Now, when you want to use this repository on another computer, first copy it to a remote server using scp:

scp –r /path/to/remote/repository.git user@host:~/git/repository.git

I like to make a git directory in my home directory both locally and on the server, to store my “remote” repositories. Whenever you update the local “remote” git repository, just use scp to copy it to the server.

When you want to get at this repository from another computer, use scp to pull down the repository, and then do a git clone or git pull to get your updated contents into your working directory.

scp –r user@host:~/git/repository.git /path/to/different/remote/repository.git

and then a git clone or git pull as necessary.
Hope this helps someone, as I was looking for something like this and couldn’t figure it out initially. It’s pretty simple but for a git newbie like me it wasn’t immediately obvious.