First steps with CODESYS Git

First steps with CODESYS Git

This is in no way a complete overview on what Git offers. It is merely meant as a primer to get you up and running with git on forge quickly.

Git is a popular open source distributed version control system. Understand and mastering the basics is easy however, the best results are achieved in learning by doing. This blogpost tries to condense the bare essentials for CODESYS Git so you can get started quickly.

Be aware that Git is a totally different beast from svn! If you have previous experience with svn you will have a (small) headstart in understanding basic key concepts of Git.

CODESYS Git usage requires a valid Professional Developer Edition License!
Please ask CODESYS to enable it's usage for free use in combination with cForge like svn

Terminology

  1. Git: 'global information tracker' or more commonly 'git' is a 'container name' for a repository
  2. Since 2020 'master' is being replaced with 'main', in this guide we will use 'main'
  3. Remote main: The remote 'main' repository, which in most cases is hosted somewhere online and it contains the entire project code and it's entire history.
  4. local main: Usually a local clone from a remote main. The local clone is an exact copy of the remote main repository and acts a local starting point for your contributions.
  5. Branch: A working snapshot of Main which acts as a point for you to add contributions in. Once you have tested the contributions (and stage/commit them), you can merge them back into your local main.
  6. Checkout: select a working branch on which you are working
  7. Stage: the act of preparing files and code changes on the current checkout.
  8. Commit: Adds staged files and changes into the current checkout branch. A username, emailadres and a commit message are to provided onneach commit. The more descriptive your commit message is, the better as this will help you search for mutations if you need to without digging into the history too much. Changes are always commited to the current checked out branch.
  9. push: commits from local branches are ultimatly merged into the local main.
    When you are satisfied with the result, e.g some feature or ticket is completed, the local main needs to be synchronised with the remote main. In order to di this we must 'push' all changes into the remote main.
  10. Pull or 'pull request': A pull request can be sent to the admin of a remote main. This will notify the admin that a new code is ready to be merged into the remote main. After checking this new code the admin can decide if he merges it (partially or entirely). **Currently I am not sure if cForge / CODESYS Git support pull requests yet.

Typical complete development cycle

Initial setup is done a few times in the development cycle, but usually significantly less then the repeated workflow, unless you like to tinker around much or you have a need for many git's

Initialisation

  • Create Remote Main git
  • load project into CODESYS
  • initialise local main git and commit loaded project into it
  • add the Remote Git as a location
  • push local main to the remote main

Repeated workflow

  • branch and checkout the local main into a new branch for your first contribution
  • after completion, stage and commit the changes onto your working branch
  • checkout the local main and merge the previous mentioned branch into the local main
  • push local main into remote main
  • eat, sleep, code, repeat

Installing Git

  1. Start the CODESYS installer,
  2. Select the installation you wish to extend with git and press "Change",
  3. In AddOns select the browse category,
  4. Now enter Git in the search bar and start the search by pressing enter,
  5. Select it and press install and follow the instructions,
  6. Wait for the installation to complete,
  7. Ready!

Add cForge Git repository

  1. Add a new "Git" repository on a project where you are Admin via "Add New..." menu,
  2. Once the Git repository has been added to cForge, you can use it to check in and out code

CODESYS svn to git migration

  1. checkout from SVN
  2. Disconnect from SVN
  3. Git > Initialize Local repository
  4. Git > Remote > Add the remote git location you made in the previous step
  5. Git > push to the remote origin

these steps should be expanded upon

Posted by hermsen 2021-07-04

Log in to post a comment.