I started working on my home automation project in 2020. I started with a simple backup script that copies the source code to a second hard drive, just in case the primary hard drive fails. When my code base started to grow I extended the script to create a (daily) second copy on OneDrive. From a backup perspective this is working fine, but it does not give me versioning and source control. Luckily, Github exists. Microsoft developed a Github extension for Visual Studio.
Make sure you update your Visual Studio installation before you install the extension. You also need to install Git for Windows. Additionally you need a Github account. After that, publishing an existing project to Github is pretty straightforward.
Open the command line and browse to the directory of the project. Execute a git init.
D:\>cd DataMario\Ontwikkeling\IoT\Verhaeg.IoT.Geofencing.Sensor
D:\DataMario\Ontwikkeling\IoT\Verhaeg.IoT.Geofencing.Sensor>git init
Initialized empty Git repository in D:/DataMario/Ontwikkeling/IoT/Verhaeg.IoT.Geofencing.Sensor/.git/
D:\DataMario\Ontwikkeling\IoT\Verhaeg.IoT.Geofencing.Sensor>
Open Visual Studio and copy/paste an existing gitignore file to exclude configuration files that could include passwords.
Then push the project to Git:
![](https://www.marioverhaeg.nl/wp-content/uploads/2023/12/image-1.png)
And finally, define the Git repository details.
![](https://www.marioverhaeg.nl/wp-content/uploads/2021/05/Sign-in.png)
Once you have published the project on Github you need to maintain it. There are three steps required to upload changes to the Github repository:
- Pull: pulls the latest version of the repository to the local development machine.
- Commit: commits the code changes to a “snapshot” of your project.
- Push: pushes the latest snapshot of your project to the repository.