Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

My favorite git trick is using etckeeper & git subtree to manage multiple machines from a single repo . A single git repo can “fan out” to dozens of instances . It’s useful even for “managed” hosts with terraform because etckeeper snapshots config with every change, catching bugs in the terraform config.

During the dev / compile / test flow, git makes a lightweight CI that reduces the exposure to your primary repo . Just run `watch -n 60 make` on the target and push using `git push` . The target can run builds without having any access to your primary (GitHub) repo.





Care to share a little bit more about this? I've been thinking of using git with `--work-tree=/` to track system files, so I'm interested in these "unusual" setups with git. Not sure I got the "fan out" concept here.

`apt install etckeeper` will setup a repo in /etc/.git for you. It tracks any changes made via apt, and it runs nightly for other changes.

On your primary repo, create dirs for each machine e.g.

  monorepo/
  ├─ Machine1/
  │  ├─ usr/share/www/
  │  ├─ etc/
  ├─ machine2/
  │  ├─ etc/

Create remotes for each machine+repo e.g. `git remote add hosts/machine1/etc ssh://machine1/etc` then `git fetch hosts/machine1/etc`

Then add the subtree with `git subtree add -P machine1/etc hosts/machine1/etc master`

When you want to pull changes you can `git subtree pull` or `git subtree push …`

If you end up making changes in your monorepo, use push. If you make changes directly on the machine (or via terraform), pull

This way you can edit and manage dozens of machines using a single git repo, and git subtree push to deploy the changes. No deploy scripts.


I call it “fan out” because it allows one repo to fan out to many deployments. The monorepo can be pushed to GitHub/gitlab and backed up regularly. It’s a lot easier to manage one big repo than dozens of tiny ones. And it helps with dependencies across machines. You can version control the entire network using the repo git commit.



Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: