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 101

Git is a very popular Distributed Sourcecode Management tool. Understanding the basics is not to difficult but the best learning is done by doing. This blogpost tries to condense the bare essentials for CODESYS Git so you can get started quick. Ps if you have previous experience with svn you have a (small) headstart to understand some basic concepts of Git, however Git is a totally different beast thennsvn.

Terminology

  1. Remote Master: The remote repository which in most cases is hosted somewhere online. 'Master' has been deprecated and is now usually renamed into 'Main' so the remote repo is called Remote Main for newer gits.
  2. Master: deprecated in favor for main. Usually a local clone from a Remote Main (Remote Master). The local clone is an exact copy (clone) of the remote repository and acts a starting point for your contributions.
  3. Branch: A snapshot of Master (Main) which acts as a point for you to make changes onto the code. Once you have tested the new changes you can merge these changes back into the local Master.
  4. Stage / unstage: Stage is the act of preparing files and code changes. Unstage is to remove or undo these files or changes.
  5. Commit: Add staged files and changes into the repository. A username, emailadres and a commit message are to provided onneach commit. The more metadat you add in your message the better as this will help you search for mutations if you need to. Be aware that the changes are commited to the local checked out branch.
  6. push: all commits from the branches are ultimatly merged into the local Master (Local Main). after this done the local Main needs to push all changes into the Remote Main. Push allows you to 'push' all local main commits into the remote main.

Basicly a single complete dev cycle looks something like this:
* 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 the local main to the remote main
* branch and checkout the local main into a new branch for your first code mutation
* after your code is done, stage and commit these changes onto your branch.
* checkout the local main and merge the branch
* push the local main into the 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!

Note: Git usage requires a valid Professional Developer Edition License
Please ask CODESYS to whitelist cForge usage as we (the community) think git usage should be free for use in combination with cForge!

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

this step should be expanded

Posted by hermsen 2021-07-03

Log in to post a comment.