As mentioned in my previous post, I have recently started using my Raspberry Pi as a server and I decided to try to host a basic Git server.
As explained in the chapter “Git on the Server” of Pro Git1, among other protocols, Git supports SSH and it is quite straightforward to setup a basic Git server via this protocol. As I can access my Raspberry Pi via ssh, I decided to give it a try! I first connected to it as user pi (ssh pi@raspberry.local), a user that is listed as a super user, and I created a new user: git (this is one way suggested in Pro Git).
| |
Then I created the directory git in /srv (see the FHS for this choice)
| |
and made the user git its owner.
| |
Then I logged out and logged back in as user git (ssh git@raspberry.local) to create a bare repository demogit.git (note that the final .git is a mere convention).
| |
Well, that was basically it, demogit.git was now ready to be the remote repo for one of a local repo! So I logged out and went back on my computer where I created a local repo and a first commit.
| |
Then I added my remote repo.
| |
🎉 Now I have a local repo on my main computer and a remote repo on my Raspberry Pi. So yes, setting a basic (and really remote2) Git server could be as simple as setting a bare Git repository in on a computer to which you have ssh access to, which is pretty neat!
Pro Git (2014), S. Chacon & B. Straub. https://git-scm.com/book. ↩︎
You can actually use your own computer, with
file:///path/to/bare-repo.gitas remote repository. ↩︎