GIT Pull Addon

Yes, make sure the files are in your repo first. I’d suggest learning the git commands before messing with it though.

Never would I ever have thought to try that, but it worked just fine. I wish I just drop my ssh key into my home directory and be done with it.

Thx.

This really should be in the documentation… :-/

Hey there folks, just set this up myself.

IMO the safest way to get started with this add on is to make the config folder a git repo via the SSH addon BEFORE starting this add on. So do git init, git pull, configure the git repo as you want it first to make sure everything is working. After git rev-parse --is-inside-work-tree returns true in the /config folder (this is what the addon runs to figure out if a repo already exists), you can add this addon.

Then, it won’t remove all the files in the config folder, it’ll just pull the existing git repo. It might be worthwhile to update the documentation for the addon to recommend this route, since the other route (initializing the git repo via the add on, which deletes everything first), is pretty risky/potentially destructive. See the code here that bypasses the “blow everything away” code if /config is already a git repo: https://github.com/home-assistant/addons/blob/cd11be29f99ad544b76679b09a33cdf86291bbe2/git_pull/data/run.sh#L118.

One other thing that’s been helpful in getting it set up – just ignoring all files to start by default, and having git own only the directories/files you want under version control. Then you don’t have to worry about git tracking the DB, any other files that show up, etc. For example, here I’m only tracking .gitignore and the custom_components directory in my repo, but all the other config files in the config/ folder aren’t touched:

*
!.gitignore
!custom_components/
!custom_components/**

Are you still getting benefit of this, now that YAML configs are being dropped little by little ?

I still use it, but that also because I use pyscript for my automations. I would also use it if I (only) used the build-in automations because there is no other way of versioning those.

New changes were made for addon configs: Public Addon Config | Home Assistant Developer Docs

Anyone figured out how to include /addon_configs which previously stored in /config (now /homeassistant) and also included in the git repo?

I’m also stuck with that (using AppDaemon). I’d like to keep using this add-on but I’d also like to have my AppDaemon stuff synced using Git now that it’s in a different folder away from my usual repository…

I guess you could write a custom script for the git pulls but the add-on is so convenient :frowning:

it is a bit surprising to me that this addon is not written in a way to preserve the config files in cases where they don’t exist on a remote repository at initial setup.

like, would it be so difficult to either initiate a backup or just copy the directory to a new .git-pull-backup directory on first run?

i am really surprised that something so destructive is available without a major warning somewhere in the process (and on the official repo too)

Actually, it does make the backup — see run.sh line 48. But the, on any error, it just exits instead of restoring the backup (line 55).

It also is broken in current versions of Home Assistant.