|
Two years ago I described how to convert an obsolete workstation into a DIY NAS for use on a Windows-machine network. The deprecated enterprise-quality machine used for that post is still in my home-lab Beowulf cluster. Recently I needed to install a local git server on same machine. Like for building a NAS, there are many recipes around. Here is mine, somewhat simpler than most.
Server side
My server has hostname c3po. You guessed it, my cluster has another server called r2d2. We log in as root on c3po and install git.
# apt update # apt upgrade # apt install git
Next we create a new user, git. You will be prompted for information on the new user. Give git a sensible password, you will need it on the client side.
# /sbin/adduser git
At this point, tutorials tend to instruct a tedious set up of ssh access for many users. In my tutorial, we skip this, and simply set that up from the client side later since I am the only user of the git server.
Now we make a first git repository. Just as an illustration, I will make a repository for Algol 68 Genie.
# su git $ git init --bare ~/algol68g.git
And that is pretty much all.
Client side
Now we move to the machine where the project is actually being worked on. There we install git as well.
# apt update # apt upgrade # apt install git
We're done as superuser now. Log in as the user that develops the project. First we set up ssh authorization, so we can easily access the git server. Note that you may have followed the ssh-keygen procedure in an earlier stage, for instance when setting up a computer cluster. In that case, do not issue ssh-keygen again, and immediately copy the key to the server.
$ ssh-keygen -t rsa $ ssh-copy-id git@c3po
Now we enter the directory where the source code sits. In our case, it will be the directory algol68g.
$ cd algol68g
Now we make it ready to be synced with the git server c3po. Mind the dot at the end of the init command, it indicates the present working directory.
$ git init . $ git remote add origin git@c3po:algol68g.git
Before we can synchronize with the git server, git wants you to properly introduce yourself.
$ git config --global user.name "..." $ git config --global user.email "..."
Now, you could open the project with VS Code. However, in a project as large as Algol 68 Genie, VS Code may complain it sees too many changes for the initial commit. Therefore, we do the initial commit and push by hand. Again, mind the dot in the add command, that is not optional.
$ git add . $ git commit -m "Initial commit" $ git push -u origin master
You now have your own local git server at your disposal!