Git without a hosted platform

People have apparently started believing that in order to use git, you’d have to also have to host the project on Github or Gitlab:

I feel that is is underreported that you can easily host Git repos on a normal Unix account. I use this all the time myself for my personal projects – I maintain far more repositories locally over SSH than I expose on hosted platforms. This is not visible on the public internet, but maybe that makes it especially mention-worthy.

How it’s done

All you need is an account on a Unix/Linux machine, which you can reach over SSH.

  1. On the remote side, set up the repo:

    mkdir -p ~/repos/foobar.git
    cd ~/repos/foobar.git
    git init --bare
    
  2. On the local side, set up the remote:

    git remote add foobar user@hostname:repos/foobar.git
    git push --set-upstream foobar main
    

There is not much more to it. Now you can push and pull.

A more detailed description that also covers SSH keys can be found in the Git Book.

What if I need more?

The approach scales and extends to bigger endeavors as well.

If a project grows and you want to work with people who can’t wrap their heads around this, you can still fall back to a hosted platform after the fact and push your repository there later.

Comments