Restore previous config from Github

Looking at a fresh install, how do I restore my configuration from Github?

git clone https://my-git-ha-repo

Do I need to run the git init command and git config user.email xxx etc?

I know its a basic question, but im very new to Git, so I guess im asking, how do I ‘re-sync’ my github backup to my newly installed instance of HA?

You’ll need to set up your git configuration (email, ssh etc if relevant) definitely, but I don’t think you do git init off the top of my head, because I think that will create a new, blank git commit history.

Please note that this is an educated guess, I may be completely wrong, I have lots of trouble remembering which bits affect what in git/github too!

will create a directory wherever you are called my-git-ha-repo (obviously whatever your repo is actually called) If you use git clone https://my-git-ha-repo . (note the .) it will dump the contents of your repo directly in the folder you are currently in.

git init is for actually creating a NEW repo, so no, if you are cloning a repo, you do NOT run init. If you are using git https:// then you also do not need to config anything, but in order to commit changes you will need to run git config. Git config is a way of setting your login/pass/etc

1 Like

ah ok, thanks very much chaps

so to summarise, and create some sort of (hopefully) usefull ‘guide’ to any who stumble across this (assuming there are other folk as daft as me!)

cd /home/homeassistant/.homeassistant
git clone https://my-git-ha-repo .
git config user.email "[email protected]"
git config user.name "username"

Do I then need to run git push or pull to ‘sync’ local and remote?
git remote add origin my-ha-repo

1 Like

This is not necessary and will do nothing. The git clone already has the remote in it.

If you plan to make changes to this installation, and push them back to github, I think you will need to (or at least its easier to) set up ssh keys in github and use the git protocol.

OK, so once I have cloned and config’d, I should be able to run git status for example, and also commit local changes to the remote backup with git add file.yaml and git commit

git commit will commit locally.

git push will push to the remote which will have already been configured by your clone.

You can verify the settings by looking in the .git folder and a file called config

thanks!

I love Git, but I am struggling to get my head around the way it works!