Hacker News new | ask | show | jobs
Ask HN: How do you sync your Git repos across machines at home?
5 points by multiplied 669 days ago
I have a multi machine setup and I don't want to use a third party service as a proxy to what I could be doing locally.

One obvious answer is to stand up my own local git server, perhaps finally put those Raspberry-pi's.

Any suggestions to improve upon this?

Even if I do go down the path of the raspberry pi, how do I configure it to hide behind the router where it is shielded from the external internet. (I want it completely disjointed from the internet if possible)

9 comments

Git is peer to peer, you can add an ssh remote that points to the directory containing the git repo on another machine.

https://stackoverflow.com/questions/4131164/how-do-i-pull-fr...

Thank you, I was considering this but I need to be able to not rely on both machines being online.
You already have everything you need to do this with just git. Just make a repo (might need to be a bare repo) on whatever machine you want to make the remote and then clone from it using ssh on the other machines. Then you can push and pull just as if the remote was in github or whatever.

If you want more functionality than that, gitlab has a free tier that can be self-hosted. same with gittea.

You don't need to use a bare repo necessarily if you want to push/pull between two working repos, without a central "bare" repo locally, you just need to tell git to update when receiving:

`git config receive.denyCurrentBranch updateInstead`

You can setup glusterfs incredibly easily. When you write to one dir it’ll auto replicate to N machines. Did this over the weekend and it took me no time at all. Support is realistically Linux only IIRC with some MacFuse stuff for OSX
How does it handle conflicts?
I use tailscale to access my machines around the world. It's secure and private. Nobody on the internet knows about this machines, even though they are servers. Easy to configure
Tailscale is one of those services that feel too good to be true. I have known about it but can't get myself to trust it.
I agree about too good to be true. I just can't believe it's free for up to 3 users and many machines. But if you look under the hood there is nothing there that you can't build on your own. It's just more hassle to do it. You can install wireguard on every machine that you own and you can manage the keys by yourself, you can add routing tables and internal DNS service. Tailscale just packages that in nice UI with centralized management.
I have my git repos in one folder ~/git and then use syncthing to sync across all machines. It works great, I can start doing changes on one machine and then pick up the work on another machine without interruption
I was thinking about this, but how does syncthing handle conflicts?
I run a self hosted gogs instance. Centralized storage is much easier to backup.
Interesting, thanks for bringing it up.
I have my own forgejo instance
Thanks for mentioning.
A bare repo on a server, which I `got push` to and `git pull` from.
Locally hosted server? AWS ECS instance?

I also realize there's Amazon CodeCommit, interesting.

what, no firewall?...some bots would be happy to know ur ip address

about git, yes a server is the answer

Yeah of course a firewall, I just don't know enough about the exact setup there, and that's part of my question.

Diving into that rabbit hole now.