News for hackers. Stuff that matters.

Ask HN: How do you sync your Git repos across machines at home?

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)

( 19 comments | on HN )
Re:Ask HN: How do you sync your Git repos across machines at... by stop50 on Saturday August 17, 2024 @07:44AM (#41273768)
I have my own forgejo instance
Re:Ask HN: How do you sync your Git repos across machines at... by multiplied on Friday August 23, 2024 @08:31AM (#41328439)
Thanks for mentioning.
Re:Ask HN: How do you sync your Git repos across machines at... by pestatije on Saturday August 17, 2024 @08:02AM (#41273880)
what, no firewall?...some bots would be happy to know ur ip address

about git, yes a server is the answer

Re:Ask HN: How do you sync your Git repos across machines at... by multiplied on Saturday August 17, 2024 @08:15AM (#41273958)
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.

Re:Ask HN: How do you sync your Git repos across machines at... by fhaldridge7 on Saturday August 17, 2024 @01:07PM (#41275987)
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
Re:Ask HN: How do you sync your Git repos across machines at... by multiplied on Friday August 23, 2024 @08:27AM (#41328407)
I was thinking about this, but how does syncthing handle conflicts?
Re:Ask HN: How do you sync your Git repos across machines at... by pavel_lishin on Saturday August 17, 2024 @03:26PM (#41277216)
A bare repo on a server, which I `got push` to and `git pull` from.
Re:Ask HN: How do you sync your Git repos across machines at... by multiplied on Friday August 23, 2024 @08:29AM (#41328423)
Locally hosted server? AWS ECS instance?

I also realize there's Amazon CodeCommit, interesting.

Re:Ask HN: How do you sync your Git repos across machines at... by simon_acca on Saturday August 17, 2024 @06:15PM (#41278441)
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...

Re:Ask HN: How do you sync your Git repos across machines at... by multiplied on Friday August 23, 2024 @08:25AM (#41328396)
Thank you, I was considering this but I need to be able to not rely on both machines being online.
Re:Ask HN: How do you sync your Git repos across machines at... by hnthrow10282910 on Monday August 19, 2024 @02:10PM (#41293305)
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
Re:Ask HN: How do you sync your Git repos across machines at... by multiplied on Friday August 23, 2024 @08:29AM (#41328422)
How does it handle conflicts?
Re:Ask HN: How do you sync your Git repos across machines at... by vineyardlabs on Tuesday August 20, 2024 @01:42PM (#41302151)
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.

Re:Ask HN: How do you sync your Git repos across machines at... by stephenr on Wednesday August 21, 2024 @04:46AM (#41308191)
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`

Re:Ask HN: How do you sync your Git repos across machines at... by mindwork on Tuesday August 20, 2024 @01:53PM (#41302271)
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
Re:Ask HN: How do you sync your Git repos across machines at... by multiplied on Friday August 23, 2024 @08:28AM (#41328416)
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.
Re:Ask HN: How do you sync your Git repos across machines at... by mindwork on Monday August 26, 2024 @12:44PM (#41359016)
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.
Re:Ask HN: How do you sync your Git repos across machines at... by KittenPassingBy on Thursday August 22, 2024 @12:16PM (#41321839)
I run a self hosted gogs instance. Centralized storage is much easier to backup.
Re:Ask HN: How do you sync your Git repos across machines at... by multiplied on Friday August 23, 2024 @08:26AM (#41328404)
Interesting, thanks for bringing it up.