How I'm using desserts for my version control

Long time no see…

But here I am again. :wink:

Well… I had this one written out for a few months now but I sadly haven’t found the time to write/try everything out yet. No wonder considering how long that one is…

But I still wanted to publish that one finally to have at least the basic version out there. I should’ve split that one into two parts but well…

What I basically wanted to tell is that I haven’t finished that section with the SSH-Keys out simply because I haven’t tried it out yet (because of other projects and the reasons outlined later on (I simply keep it off 99% of the time) and I don’t wanna tell you something that I haven’t done yet.

So yeah… I’ll update that blog post some day in the future, but for now enjoy. :)

“Today” I wanna talk a bit about an idea I recently had inspired by one of my university professors. Well… A few weeks ago I saw a neat little deal for a complete kit with a Raspberry Pi Zero W and thought to myself… why not? A few days later it arrived and was thinking about a project I could do with it. I tried different things like some general Linux Desktop shenanigans or Retropie a special OS image built on top of Raspbian which allows a cool emulation system for retro consoles. But I didn’t really feel like “that is it”… and also needed some extra equipment for that Retropie stuff haha

Recently one of my university professors gave me a really interesting idea by barely mentioning the words “private Git server” during a lecture. Then I leaned my head downwards by about five degrees and saw my poor little Raspberry Pi just sitting there and waiting.

It was in this moment where everything came together. Why don’t I just repurpose this fella as my own private Git server? And that’s what I did. Now that I’ve made it kinda was easier than I thought. So that’s why I wanna share this with you out there. :)

You see… Technically with today’s ecosystems and other cloud-based platforms there “shouldn’t” be a reason why an average person would actually need this. There are a lot of platforms like Microsoft’s GitHub which even offer private online hosting of your code-repositories with the corresponding advantages that a Git repository and version control offers. So why did I do this again?

  • I have this system 100% under my control which means a Microsoft for a example has no control over my code that I’ve written. So the privacy aspect is ideally even more protected than with a online service.

  • The cost. You see… With an unlimited private repository service there is always some sort of cost involved. Whether it would be money or other “information”. Always remember kids… If you’re not paying for the product then you are the product. And with that method you only have a one-time cost associated with buying the Raspberry Pi (if you don’t have one already…) and some very small electricity costs. If you don’t let it run 24/7 these costs are basically non-existent, especially if you use less power-hungry versions like the Zero line like in my case.

  • And last the “fun factor”. You see… You could call me a nerd or something else in that manner. I don’t what term is popular with the kids these days. But I guess you know the drill. Whatever term you chose, well that’s kinda true. I love tech and software and hardware and all of that stuff. And I also love playing around with that stuff. So for me this is a project to play around and have a bit of fun while creating something that I can actually use for my other projects. I mean… That reason alone is more than enough for most people. :D

Now that we have that out of the way let’s get onto the actual stuff.

So we start out with the plain and basic Raspberry Pi just like it came out of it’s box. Now we use a simple micro SD-card and flash whatever operating system you wanna use. I’m using Raspbian because it is the officially recommended operating system for the Raspberry Pi but I’m pretty sure you could use basically any other Linux based operating system and still get along with this “tutorial”.

With our freshly formatted SD-card in the Raspberry Pi we now boot it up for the first time and set up the Pi. I don’t wanna go too much into detail on that part since it is pretty intuitive and not really on the topic and could actually be very different dependent on which operating system you chose. A little tip from me. Enable SSH-Access on your Raspberry Pi so you can access it from your main PC and you can you everything from here on, on one computer. Now that the Pi is properly set up we go on with the process of setting up our private Git server.

First of all, make sure that you use the newest version of our software that you’re using (OS Software, Package Manager (sudo apt-get update) and if it isn’t pre-installed already (if you are not using Raspbian), install Git with sudo apt-get install git

Now we create a folder wherever you like. This folder will be housing all of your repositories which you wanna create. I’m creating it in the root directory of my little Pi and call it “repos”. So use the cd command to navigate to your target destination for your folder and then execute sudo mkdir </code> (in my case sudo mkdir repos) to create your repositories folder.

Now we use the cd command again to navigate inside this folder we’ve just created and inside there we create yet another folder in the same manner. This folder will represent your single repository with all of it’s data. So execute the mkdir command again like this… sudo mkdir </code>. I'm using the name "testproject" so for me it's sudo mkdir testproject.

Then we go into this folder that we’ve just created and now execute the following command: sudo git init --bare This command will initialize a minimal bare-bones git repository inside this folder which is theoretically ready to use. The only thing left to use as a Git server is the outside access to this repository we’ve just created.

To accomplish that goal we just go back one folder to our repositories folder (repos) via the cd command. In there we execute the following command. sudo chmod -R 777 . This command recursively sets the access level of each folder and file which is inside our repositories folder so that everyone who can access to the Pi has read and write access.

Don’t forget to change the password of our Pi from the classic raspberry to something less crackable so we don’t accidentally make our Git server public. :D

But now we are done with the basic setup on our Raspberry Pi and we have a private Git server on our Pi up and running. (if we leave the Pi running, or not… :D it’s still a server kinda haha )

So now we get to how we can actually use this. To use our freshly initialized Git repository we have to do the following steps.

Create a folder/directory in which your new Git repository will be based. Then open and navigate the command line to the corresponding directory that you’ve just created. Inside you can execute the following command. git clone pi@IP_ADDRESS:/repos/YOUR_PROJECT An example would be git clone pi@ (You may need to enter a password. That would be the one which you use to login to the Raspberry Pi. And make sure that Git is also installed on that device.) That command clones our Git repository from the private Git server to that folder but since there no content inside the repository this will be “empty”. Well… Not really empty. There will be a .git folder inside which configures the background stuff Git and the repository is doing. To put it veeeeeery simple… ^^

With the repository in place you can finally do the really cool Git stuff you are actually here for. Cool does not have to be taken literally though since this is all pretty nerdy overall…

We can now add some files to our repository. Doesn’t matter what or which… Whatever you wanna do inside the repository. ;) I personally think that if you are interesting in setting up a private Git server then you at least know how to commit and push something to a Git repository. But if you need a reminder or want to save one internet search I’m giving you a really quick rundown.

After you added your files enter the command line inside the directory where your repository is. Then execute the command git add . This adds all edited/added files inside the repository to the “staged changes” When those files are staged execute git commit -m "YOUR_COMMIT_MESSAGE" to commit your changes and finally execute git push to push your changes to your private Git server. (again here you might need to enter the password I’ve mentioned before…)

And that’s it. You’ve created your own private Git server and pushed your first commit to it. So that’s really great and I could end this blog entry right here since we have a usable product now… But that would be a bit too easy and we could make our lifes a bit better from here. :P

The first thing I’d like to change from this baseline is the fact that we are currently using a password to authenticate ourselves to the Raspberry Pi. For many reasons this is kinda unoptimal which I don’t wanna go too far into detail because… Well… This security topic would be a blog post by itself. ;)

Nevertheless we are currently just using basic authentication with a simple password which poses a security risk. I mean… If you only use your private Git server locally inside your network without any outside connections and isn’t even online 24/7 and just only when you need it (in very short bursts) then this isn’t really an issue I guess. If you think about it… You can’t get remote access to a device that isn’t even turned on. ^^ 11/10 security in my book. :D But this is kinda annoying to turn it on or off every time you use it, especially if you wanna use it frequently. So we need a better solution.

That’s where the so called SSH-Keys come in. The SSH-protocol or Secure Shell Protocol (yes IT people are really bad at making acronyms/abbreviations…) is a different authentication method where the security is a lot higher than the basic authentication.

But that is where I put a little cut. As I said, that’s where that explaination with the SSH-keys would come in but yeah… That’ll come in the future.

See you hopefully soon


Further Resources:

PS: I’ll update these informations with more in resources in the future. :)