4 ms·
Could you elaborate on using git subtree for adding dotfiles to /etc or any other root directory?
by blankdata 1y ago
Could you elaborate on using git subtree for adding dotfiles to /etc or any other root directory?
- tonymet 1y agomind you it's one of a number of patterns that subtree let's you fan-in and fan-out from a single repo. It's helpful if you want to manage multiple directories and machines from a single repo. 1. git init /etc 2. git init /home 3. (in home) git remote add s/etc /etc 4. (in home) git subtree add -P etc s/etc master # adds a prefix etc , from remote s/etc . This starts the subtree syncing You can now edit files in either place. to pull changes from /etc: git subtree pull. to push changes to etc: git subtree push. git is now managing the commit shas and diffs for both directories. The home repo is the "canonical" one that you backup , push to github/gitlab etc. /etc can just stay local for "deployment". You can take it a step further by editing the home repo on another machine. this pattern lets you fan in and out to multiple machines and etcs so you can manage all of the variations from a single repo. describing it is more complicated than just doing it. It's really just push/pull which triggers a normal merge over multiple directories.
- tonymet 1y agohttps://dev.to/tonymet/how-to-put-everything-in-git-2b3d https://dev.to/tonymet/how-to-put-everything-in-git-2b3d This is a variation of the same idea with some illustrations
- tonymet 1y agoyou could think of it as a "monorepo" for multiple machines
- tonymet 1y agohere's an example to a remote machine `pi4.local` /etc dir. If you want to deploy on push set `git config receive.denyCurrentBranch updateInstead` . if you want to deploy manually use `warn` git subtree push -P pi4.local pi4.local master