Did you know it's super easy to self-host a git repo over SSH? If you're not looking for a full web based git interface (like GitHub, Gitea etc.) you can use the steps below to set up a simple repo over SSH. All you need is SSH access to a server that you own. You can set up as many self-hosted repos as you like. It can even be as simple as a raspberry Pi on your local network.
There are two simple parts to this. First you set up the remote server one time only. Next you add the remote server as a
remote for your local repo. After that you can just
git push as normal.
To get started SSH into the box where you want the repo to be hosted:
Next you're going to create a folder for the repo,
cd into it, and create a bare git repo:
mkdir my_repo_name.git cd my_repo_name.git git init --bare
If you want to also serve a read-only copy of this repo over HTTP, then make sure the folder is in a public web root, and run this:
Now you can add this git remote to your existing git repo just like normal:
git remote add origin firstname.lastname@example.org:my_repo_name.git git push -u origin master
There you go, you now have a self-hosted remote you can push to over SSH.
If you want this to be a backup repo only you can add it with a name other than
origin like this:
git remote add backup email@example.com:my_repo_name.git git push backup master
After this any time you want to push to
backup instead of
origin you just do:
git push backup.
Enjoy your self-hosted private git repo!
P.S. If you're looking for a hosted private git repository with a web interface check out hostedgitea.com.
Latest comments (0)