Custom Git remote with SSH

I have long heard the benefits of a custom Git server. I have been curious to try this, but not interested enough to commit to being a sysadmin for my own server: setting up a git user, installing a special shell, worrying about ports and permissions… yuck 🤢

I am, however, able to SSH into a server at my university, and it turns out this is all that is necessary to be able to setup a custom Git remote. After creating a bare Git repository on the university server, I am able to set it as a remote on my local Git repository and push to it over SSH using the same credentials I use to login in the terminal.

This also means I get to use custom post-recieve hooks!

I contribute to a couple repositories that are mirrored in multiple locations. I created a script that will push this repository to each remote, and saved this script as hooks/post-receive. Now, every time I push changes to the university’s server, it will automatically push those changes out to all remotes.

For another project, I created a post-receive hook to build and deploy a web application each time I push new changes. It would be possible to use this same technique to build and deploy a Jekyll site on each push, a la GitHub Pages This has made my life much easier.

While I certainly won’t be moving any of my repositories off of GitHub anytime soon, custom remotes offer a lot of flexibility through server side hooks, and setting up a custom Git remote is easy if you already have an SSH account somewhere that you can use.