Setting up Raspberry Pi as a git server

Fernando B 🚀 on June 06, 2019

Update 1 June, 6th: I have installed gitea to test it out as well, as per comments. It is awesome! Their docs are pretty good to get you started, i... [Read Full]
markdown guide
 

Interesting approach, but I think I would use a software like Gitea for the remote-git stuff :)

 

I use Gitea myself and definitely recommend it or even a self-hosted GitLab CE setup over this 'hack'. I mean you could just do git init --bare in a directory (reponame) under the git user directory, set up sshd_config and off you go. Just use git remote add origin git@ip.or.domain:reponame.git on your local machine. If you wish to keep the GitHub 'mirror' updated, set up an access token and a post-receive hook containing git push --mirror --quiet https://ghusername:accesstoken@github.con/ghusername/reponame.git.

All of this can be done with a few clicks on the Gitea/GitLab UI. Good post by the way :)

 

Glad you liked it. Tbh I didn't even know gitea existed until I posted this comment and Julian brought it to my attention.

Yes there are always tons of ways to do something, I am no expert on git but I need to get more familiar with --mirror for sure since I haven't used it before.

Btw I just got done installing gitea, and it's looking good!

It's just the Blade templating engine, so you can customise it a lot. Clone the go-gitea/gitea repo from GitHub and look for the templates folder and move it to the custom folder in the Gitea's installation directory. My setup is at git.ghosh.pro. Cheers!

 

Will definitely give that a try, looks like that is a full front end, right?

 

Yes, it's a lot like GitHub, just that it's free and open source and you can host it on your own server.

 

Thanks for this post! Definitely a good use case for those unused Pis some of us have lying around! Just wanna double down on how important I think this piece you touched on is:

USB thumbdrive if you want data on a thumbdrive rather than Pi SD card

As a person who likes to play around with Raspberry Pis a lot, you will definitely want to use an external HDD if you care about your data at all (and in the case of git I imagine you do). 😛

SD cards just aren't designed for the kind of file access patterns of an OS.

If you do plan on using an SD card to get started, though, disabling swap is a must. Otherwise with the Pi's low amount of RAM your OS will be swapping memory to disk a lot and this will thrash the SD card. 😵

 

Yes SD cards are super duper slow when it comes to R/W. Definitely will need a drive for this task.

Thanks for the disabling swap suggestion, will keep that in mind.

code of conduct - report abuse