Setup a Local GIT Server

If you have created various pieces of code (shell scripts, conky config, etc.), you may want a way to maintain/backup them. One very common way to do so is to use a git server.

You can use one of the many git repositories on the internet, or create a local one.

This short guide walks you through setting up a local git server, which can then be integrated into whatever backup strategy you have. This ensure that all revisions/changes are backed-up as well, not just the latest versions of the files.

This example assumes the following:

  • A directory named /development/repo1 contains the code to be maintained
  • A directory named /server will contain the local repo
  • Existing folder contents should be pushed to the new git repo
GIT_DIR=repo1

Install GIT Server

sudo apt install git

Server Setup

cd /server/${GIT_DIR}
git init --bare

Client Folder Setup

cd /development/${GIT_DIR}
git init
git add -a
git commit -m "Initial repo" -a
git remote add origin /server/${GIT_DIR}
git push origin master

Leave a Reply