Skip to content

Instantly share code, notes, and snippets.

@david-bergstrom
Last active February 21, 2023 21:18
Show Gist options
  • Save david-bergstrom/3b5f9045cd1c484c725dd801f5fd4afb to your computer and use it in GitHub Desktop.
Save david-bergstrom/3b5f9045cd1c484c725dd801f5fd4afb to your computer and use it in GitHub Desktop.
A short tutorial on how to use git without Gitlab/Github

So, you cannot access Gitlab/Github.. What now?

Git is by design not a centralized version control system. If you only need to collaborate with yourself and/or want to have your changes on more than one machine you can follow this quick tutorial to do so.

This guide requires:

  • Access to a ssh server (university, personal server or work server)

Setting things up

Server setup

On the server you can create a local bare git repository using the following commoand:

mkdir bare-repository
cd bare-repository
git init --bare

This initializes a bare repository, which unlike a regular Git repository, can only be accesed by interacting using another Git repository.

You can then, if you have a git repository on the server use the following command inside the repository:

git remote add bare `path-to-bare-repository`

This command adds another remote to you git repository which points at the newly created bare repository. You can now, almost like normal, run the following command:

git push bare master

In order to push to the newly created repository.

Your own computer

You can now add the remote repositiy as a remote on your personal computer, by running the following inside your repository:

git remote add bare username@server-address.example.com:<path-to-bare-repository>

And then, push/pull (almost) like normal:

git push bare master
git pull bare master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment