Technical Article

Managing Multi-user PLC Programming: Git Version Control

October 13, 2022 by Shawn Dietrich

PLC and other automation project software can be easier and more efficient to update and maintain thanks to the introduction of Git control, already a staple for typical programming of large-scale projects.

Git is an open-source version control application that maintains versions of files stored locally on users’ computers. 

This software helps businesses and software developers track changes to files throughout the development process. Users configure Git to monitor a folder which is called a repository. When Git recognizes changes have been made to the repository, the software will require the developers or users to stage and commit changes (with documentation in the form of commit notes) or pull the latest changes from the repository. If the changes are not warranted, the user can revert back to previous versions. 


Multi-user Programming

When using a remote repository, multiple developers or users can work on the same files at the same time and Git will merge the changes to the main branch. Each developer works on a separate branch and then commits to the main branch. Git will handle merging the changes automatically. While users can version control any file within the Git workflow, Git started with software development teams being able to work simultaneously on the same project via the clone repository feature. Cloning a repository makes a copy of the repository so that developers can work on the project locally. Once changes have been committed locally to Git, users can choose to push the changes from the cloned repository to the remote repository. 

Computer software generally contains multiple files during the development phase so having a repository that is version-controlled helps manage the project efficiently.


PLC programming with multiple developers possible with merging branches on Git

Figure 1. The ability to merge branches of code from different developers is a useful feature of Git that prevents disrupting the main branch or other developer’s work. Image used courtesy of Copia Automation


To Merge or Not to Merge?

The merge feature of Git is part of what makes Git so powerful and useful. Say we have two developers working on the same project. One user is working on the front-end user experience and the other developer is focusing on the database connection code. 

Using Git, there would remain one main branch that contains error-free, functioning code, and both developers would have their own branch named accordingly. As each developer works on their section of code, they can commit changes without disturbing the working main branch or the other developer's branch. 

Once complete, a senior developer can signal Git to merge the two branches—Git will determine which files need to be updated and which ones don’t. This feature only works with recognized file types typically found with recognized computer programming languages such as JavaScript, CSS, HTML, C++, C#, and some word documents, with other file and project types being added on a regular basis. Another feature of Git is seeing the changes that were made by other developers. 

PLCs are programmed using proprietary programming environments, unique to the specific manufacturer, which save the project to a file type not generally recognized by Git. This doesn’t mean you can’t still use Git to version control a PLC project, it just means you won’t be able to take advantage of the advanced features. 

Microsoft' Azure Dev Ops Services utilizes the Git workflow with their cloud remote repositories

Figure 2. Microsoft’s Azure Dev Op Services utilizes the Git workflow with their cloud remote repositories. Image used courtesy of Azure Dev Op Services


Software Using Git

The Git workflow is so popular and useful that major software companies like Microsoft have utilized this structure and are currently using it with their cloud remote repositories. 


Copia Automation Git software so multiple developers can make comments to rung changes

Figure 3. Using Copia’s software, users can make comments directly to rung changes and work with multiple developers on the same project. Image used courtesy of Copia Automation


Copia Automation is an industry leader in using this online repository, specializing in using Git for industrial automation software. They support many different makes of PLCs and make use of the Git workflow, meaning you can view the source code with the online or desktop app, comments can be made directly to rung changes, and multiple developers can work on the same project by making use of the multiple branches and merge features. This workflow is different from what most PLC programmers and maintenance staff are used to, but the benefits can pay off when you need to access backup programs remotely or if you develop code with a team. 

Copia's rendered ladder logic of a Beckhoff TwinCAT3 TcPOU file

Figure 4. Copia’s rendered ladder logic of a Beckhoff TwinCAT3 TcPOU file. Image used courtesy of Copia Automation


Version Control PLC Code

A big difference between PLC code and computer software code is that PLC code is not compiled; you can see the code solved in real-time without any breakpoints, you can upload the code from the PLC to your PC, and sometimes the project is one file. Some programmers feel that simply because we can upload the latest code from the PLC, this must mean that the PLC always holds the master copy of the code. This can be a dangerous way of thinking because PLCs are not bulletproof and if you don’t have a backup of that code you might lose a lot of hours trying to replicate it on the factory floor. 

During the development process, multiple programmers need to work on the same file at the same time and manually merging code from multiple programmers can be a tedious full-time job. With the use of Git and Copia’s remote repositories, PLC programmers can protect their work and work simultaneously with other programmers. With Copia’s ability to render ladder logic, function block diagrams, and structured text, senior programmers will be able to perform code reviews without having to open multiple programming environments. 

Currently, Copia only supports a select number of PLC and some robot vendors but with plans to expand the list in the future. 

Featured image used courtesy of Canva