simplest remote git repo howto (1.5 steps)

There seem to be lots of multi-step, ssh to the server style instructions how to create a new remote repository, and then push to it, but they’re all much more complex than git init.

I have many many local repositories that I decided to backup on my server, and then I can push&pull from them from my other computers too.

so – to the 1.5 steps:

0.5 create a new script called ‘’ (customizing the $ssh_setting value for your ssh-able server)


if [ -z $1 ]; then
    echo "usage: ./ RepoDir"
    scp -r  $1/.git $ssh_setting/$1
    cd $1
    git config --add alias.backup "push --mirror $ssh_setting/$1"
    ssh "cd git/$1 && git config --bool core.bare true"
    git config remote.backup.url $ssh_setting/$1/
    git backup
    cd ..

1. You can then run ./ YourLiveRepo which will create a full (but bare) copy of your repository, and add an alias that will allow you to run git backup to mirror all changes on all local branches to the backup.

The script also creates a remote.backup link that you can push and pull from in case you’re then going to clone that repo like a ‘normal’ ssh based remote.

On one local computer I can thus create a new shareable repository by running NodeJSProject

and then my new coworker can then clone it and start pushing updates:

git clone user@yourserver:~/git/NodeJsProject1