Using Github with SmartThings

Hi! I am new to this, but cannot figure out the Github integration.
I have enabled Github on ST and it says it’s connected.
How should I install stuff using Github? I assumed (probably wrongly) that if I click Fork while I am on my Github page, it should automatically show up in ST, but it doesn’t.
So far I have been doing the “new device handler” - “from code” and that works fine, but I would like to understand the Github option.
Is there a step I am missing?

Select update from repo in either device handlers or smartapps and then select what you are trying to install.

If you explore GitHub you will see that there is a hierarchy that starts with usernames. Under that you will have a number of ‘repositories’, often called ‘repos’ for short. Each repository may also have a number of ‘branches’, with the default historically being called ‘master’.

When you create a new branch you effectively take a copy of another one, often the master. You can then work with the files independently and then merge any changes to and from other branches.

As part of the setup process for GitHub in the IDE you are normally invited to ‘fork’ a copy of the SmartThingsPublic repository, which belongs to the SmartThingsCommunity username. A fork is a complete copy of a repository including all its branches. Forking someone else’s repository creates a repository of that name in your account. Changes made in forks can be merged to and from their parents.

That’s the GitHub end. The IDE acts as a client to GitHub. In the Settings on the Device Handlers and SmartApps page you can add repositories by specifying the username, repo name and branch. You may find you already have one with your username, SmartThingsPublic and master.

You will have two buttons saying Update From Repo and Commit Changes. Pressing either gives you a choice of repositories to connect to.

Update From Repo lets you download new or updated files from the chosen repo.

Commit Changes lets you add your file to the repo or upload changes.

ST has a particular folder structure and folder and file naming convention. It maintains that for you. Repos not following that convention will not work automatically with the IDE.

The original thinking seems to be that SmartThingsPublic would become a shared repository for the community. You’d develop stuff in your own fork and when ready you’d ask for changes to be merged into the main repository. Similarly you could make changes to other people’s code and request those changes be merged in.

That has largely fallen by the wayside. People share details of their own repositories instead.

1 Like

Thank you! This is starting to make sense now.