Almost all industrial programmers will use some sort of basic version control at the file system level. This generally consists of keeping copies of dated files and folders in a central file folder structure. Until recently I kept a project database listing clients at the first level, site surface locations at the second level and project files with dates one level deeper. But I have found a better way.
In my recent learning about software development I have stumbled upon GitHub and GitKraken. They are related through the open source version control software git. Software developers use this software extensively to keep their projects organized, version controlled and will probably find this post a little odd. Industrial automation programmers are just a few years behind when it comes to use of development tools.
Now there are a pile of resources regarding git and other version control software on-line. There is even a book called Pro Git available for free reading when you have the time. I will not go into all the details but here are the basics on how to use git (through GitKraken) to keep various versions of your automation project files.
We are going to start a new project folder using GitKraken. Then we will put some SCADAPack Telepace and Redlion HMI files in there for version control. So get over to Axosoft’s website and download the app. GitKraken has a version of the git software ‘baked in’ so you do not need anything other than that and your typical RTU platform development software.
Lets setup a new Project in GitKraken. Create a Project folder on your hard drive or desktop.
Open up GitKraken. You might need to create an account or login with GitHub to use it. I’m logged in already and had a project open previously.
Once you get to the app’s main page click on the folder icon in the top left corner of the screen and select Init. This will pop up the dialogue for creating a new git repository.
Browse for your new project folder. Enter a name (I usually use the surface location of the site). Leave the other options at their defaults for now. Then click on Create Repository.
GitKraken will place a Readme.md file into the project directory and create the “repository’s” first commit. A “repository” is simply a folder that git is keeping track of. You can tell where a repository is because it typically has a hidden “.git” folder in it. A “commit” is a snapshot of the folder and its files. Commits are generally made at logical stopping points in your project, but feel free to commit as often as you need to.
At this point you can delete the Readme.md file if you wish. I am going to create a blank Telepace file and a blank Redlion Crimson HMI file to get this project started.
You will notice in GitKraken it has picked up that there are new files in the folder. It shows you which files were added, changed or deleted in the stage files dialogue.
I am going to ‘stage’ these new files and then commit them, giving the commit a name and a description.
You do not need to do anything else. GitKraken using git now has two previous versions of this folder saved with commits. As you add or change files to your project GitKraken will detect that and allow you to stage the files and commit them to the database. This process might seem a little cumbersome but it is worth it!
I made some changes to the HMI and Telepace files. GitKraken picked up the changes and is letting me know files were changed and the project differs from the last commit.
Stage then commit the changes.
Now the biggest change for most industrial programmers will be that you no longer have to keep dated versions of your RTU or PLC program files in the project folder. The previous versions are contained in the commits, more specifically the changes between commits are stored in the .git database.
Look for a later article that shows how to use branches and how that could be used in an industrial environment.
Git and its cousins can commit changes on all types and most sizes of files but they work best with text based files because storing the changes is easier and uses less space on disk. With binary files where the entire file is rewritten even for minor changes git/GitKraken needs to store each changed file in its entirety. This is not a problem for modern hard drives which are pretty large, but it is worth knowing if your project folder inflates to a large size after a lot of commits. From experience I know that ROCLink files and most HMI projects are binary files like this.
One thought to “Using git for Industrial Automation”
Comments are closed.