Arun Ramamoorthy, PhD Tue Feb 20

How to Start Using Git in Industrial Automation Projects

Hey there! I'm Arun Ramamoorthy, a Senior Control Systems Integrator at Vertech. In this article, I'll guide you through the process of getting started with Git in your industrial automation projects. Git is a powerful version control system that can help you manage and track changes in your code, collaborate with team members, and ensure smooth project development. So, let's dive in!

 

Understanding Git Basics

Before we jump into using Git, let's quickly go over some basic concepts. Git is like a magical genie that keeps track of changes in your code and allows you to merge different versions seamlessly. In Git, you work with branches, which are separate versions of your project. Each branch can have its own features and changes. You can create new branches, switch between branches, merge branches, and do so much more with Git.

 

Basic Git Commands

Now, I'll walk you through some basic Git commands and how they can be used in your industrial automation projects. By mastering these commands, you'll be able to effectively manage your code, collaborate with team members, and ensure smooth project development.

Imagine you're working on a project to create a drawing of a tabby cat.You start with a simple cat and gradually add features like a body, whiskers, and a bowtie. Each feature represents a change in your code.

git merge

Use the git merge command to combine changes from different branches into a single branch. It is typically used when you want to merge a feature branch into the main branch. In our example here, we’re merging the “tabby” branch, which features golden coloring and stripes, with our master branch.

git merge command example using tabby cats

git checkout

The git checkout command allows you to switch between different branches in your Git repository (repo). It is used to move from one branch to another, enabling you to work on specific features or bug fixes independently. Here, we want to use checkout to move from the “tabby gray” branch to the “tabby golden” branch.

Screenshot-20240214-131605

git push

With the git push command, you push local revisions to a remote repo. After making changes and committing them to your local branch, you can use this command to send those changes to the remote repo. It allows you to share your code with team members and collaborate effectively. In this example, we’re pushing the “tabby gray” branch from our local repo to the remote repo.

git push command example using tabby cats

git pull

Use the git pull command to fetch changes from a remote repo into your local repo. It ensures that your local code is up to date with the latest changes made by other team members. You should regularly use this command to stay in sync with the remote repo. This example shows how another team member working on the “tabby 007” branch can pull the “tabby gray” from the remote repo to their local repo.

git pull command example using tabby cats

git cherry-pick

The git cherry-pick command allows you to select specific features from one branch and apply them to another branch. It is useful when you want to pick and choose specific changes without merging the entire branch. Here, the person working on the “tabby golden” branch on their local repo can cherry-pick the whiskers and nails features of the master from the remote repo.

git cherry-pick command example using tabby cats

These are some of the essential Git commands that you'll use frequently in your industrial automation projects. While this may seem like a lot, each command takes less than a second to implement, so the benefits far outweigh the time spent learning and executing them.

 

Using Git in Your Projects

Now that you have a basic understanding of Git, let's see how it can be applied in your industrial automation projects. In Git, you would start by creating a branch for your project. This branch acts as a separate version of your code. You can make changes, save them, and add new features to your branch without affecting the main codebase. This allows you to experiment and work on different features independently.

Once you're satisfied with a feature, you can save your changes and push them to a remote repo. The remote repo serves as a central location where you can store and share your code with team members. It's like a cloud-based storage for your project.

Collaboration is a key aspect of Git. You can create different branches for different team members to work on specific features. Each person can make changes, save them, and push them to the remote repo. This way, everyone can work on their own features without interfering with each other's code.

To ensure smooth collaboration, it's important to communicate with your team members. Daily stand-up meetings can help you discuss progress, assign tasks, and resolve any conflicts that may arise. Pull requests can also be used to review and merge code changes. This allows team members to provide feedback and ensure the quality of the code before merging it into the main branch.

 

Best Practices & Tips When Using Git

Here are some best practices and tips to keep in mind when using Git in your industrial automation projects:

  • Regularly pull changes from the remote repository to keep your local code up to date.
  • Use descriptive commit messages to explain the changes you've made. This makes it easier for others to understand your code.
  • Create separate branches for different features or bug fixes. This helps keep your code organized and makes it easier to track changes.
  • Resolve conflicts promptly. If two people make changes to the same code, Git will flag it as a conflict. Use tools like Visual Studio Code to resolve conflicts and merge changes smoothly.
  • Use a ticketing system, like Jira, to track and assign tasks. This helps keep everyone on the same page and ensures that all requirements are met.
  • Regularly test your code in a test environment before deploying it to production. This helps catch any issues or bugs early on.

Remember, Git is a powerful tool, but it does require some learning and practice. Don't be afraid to ask for help or seek out additional resources to deepen your understanding of Git.

 

Congratulations! You now have a solid understanding of how to start using Git in your industrial automation projects. By implementing Git, you can effectively manage code changes, collaborate with team members, and ensure smooth project development. Remember to follow best practices and communicate with your team to get the most out of Git. Happy coding!

 

References:

1. Inspired by "Git Explained with Cats" by @girliemac.

avatar

Arun Ramamoorthy, PhD

Arun is a Senior Control Systems Integrator based in Ottawa, Canada. He joined Vertech in 2017 after 11 years in the Water/Wastewater controls industry, serving various customers in the southwest region of the USA. Arun loves the flexibility and power of the Ignition system and has earned Inductive Automation’s Gold certification to better serve the controls and business needs of his customers. In his personal life, he enjoys outdoor activities like hiking, ice skating, and astronomy.

COMMENTS

RELATED ARTICLES

SUBSCRIBE TO OUR BLOG

Sign up to get the latest from Vertech delivered right to your inbox.