Skip to main content

Git

Download

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

A Git flow diagram


This document covers the proper steps for your daily Git workflow as well as initial set up and configuration.

note

This process document assumes the use of Visual Studio Code. If another IDE is used, the steps may need to be adapted to that software.

note

This process document assumes a Windows installation. If you are installing Linux, please contact Paul Burt for specific instructions.

Configure the Ignition Project for Repository Management

caution

Before starting this process, ensure that all current Ignition services are stopped.

Download Ignition

From the Inductive Automation Software Downloads page install the correct version of Ignition. The correct version can be found in the Wiki page of the associated project.

note

Be sure to download the file zip and not the installer.

alt text

Configure Ignition

Once the download is complete, extract the folder to a non-protected location (i.e. your desktop) and name it the Install Designation. Naming the folder the Install Designation is not required for functionality, but makes process management, file control, and trouble shooting, much easier. The Install Designation can be found in the Wiki page of the associated project.

Move the folder to C:\Program Files\Inductive Automation. You will need administrative priviledges.

Open the ignition.conf file found in the data folder. In this configuration file, there are four values that need to be changed. Set the following rows equal to the Install Designation. The Install Designation can be found in the Wiki page of the associated project.

wrapper.console.title
wrapper.name
wrapper.displayname
wrapper.description

Once the values are updated, save and close the file. You will need administrative privileges.

Navigate back to the source folder and launch the install-ignition.bat file.

Launch the start-ignition.bat file.

Launch your Windows services page and verify that the service installed correctly. You should see the Install Designation as the Name and Description of the service and the status should be Running.

alt text

note

To avoid port collision issues, it is best to set the Startup Type of these processes to Manual.

Navigate to your local host and finish the install.

Navigate to the Files section of the repository you are setting up

alt text

Select the Backups folder, select the most recent backup, and select the Download button.

alt text

Once the download is complete, restore the project from the gateway.

Configure the Repository

In VSCode, open the explorer tab and mount the project folder. (C:\Program Files\Inductive Automation\Install Designation\data\projects\Project Name)

Launch a terminal and run the command

git init

Navigate to the associated repository page in ADO and select the Clone button.

alt text

Copy the HTTPS URL by selecting the copy button next to the URL.

alt text

Go back to your IDE terminal and run the command

git remote add origin <copied URL>

Configure your access by running the following commands.

git config --global user.name <first.last>
git config --global user.email <ADO Email>

Sync your local repository with the ADO repository by running the command

git pull origin main

Your repository is now configured.


Working Branch

caution

While it is possible to work in your local main branch, it is bad practice and pushes to main are not permitted without an approved Pull Request.

Every developer will work within their own development branch. There are multiple methodologies but in this document, we will cover Critical Technologies's reccommended process.

Run the command git checkout -b <fLast/dev>

This will create your local development branch.

Run the command git pull origin main

This will pull the contents of the main branch into your development branch.

Publish your branch to create your origin development branch.

note

It is good practice to regularly pull from main on your dev branch to keep it up to date.


Commits

To commit work, navigate to the Source Control tab in VSCode.

alt text

Select the items from the working tree that will be on the commit and then select the stage changes icon.

alt text

Enter a brief description of the commit in the commit message box and then select the Commit button.


Pull Request

Create a Pull Request

In order for completed work to be pulled into the main branch, it must be pulled after a successful review of the work submitted also known as a pull request (PR).

Navigate to the Pull requests page under the Repos tab.

alt text

Select New pull request. From the drop down, choose the correct branch to pull from, add a descriptive title, a thorough description and all associated work items for the PR.

alt text

Once all the correct data is entered, select Create.

Review a Pull Request

In order to review a PR, you will need to checkout the branch associated with that PR. Navigate to the PR you want to review and copy the branch name.

alt text

Launch VSCode as an administrator. Ensure you are directed at the correct repository folder and run the command

git checkout <copied branch name>

Launch the project designer. Select the Sync File System Tag and then merge changes from the gateway. Your repository is now synced with the PR.

alt text

Be sure that once you have completed the review, you add any comments directly to the PR and Approve or Reject depending on your findings.

Complete a Pull Request

In order for a PR to be completed and merged into the main branch, three conditions must be met:

  1. At least two reviewers have approved the work.
  2. All comments are resolved.
  3. At least one work item is associated with the PR.

If all these conditions are met, anyone can complete the PR.

From the PR screen, select the completion drop down and select complete.

note

Upon PR completion, associated tasks are marked as complete and the associated branch is deleted.

alt text


Appendix A: Install Git on Windows

  1. Visit the official Git website
  2. Click on the "Download" button to download the latest version of Git for Windows.
  3. Once the download is complete, locate the downloaded file and run the installer.
  4. Follow the installation wizard instructions, accepting the default settings unless you have specific preferences.
  5. You can choose the components to install during the installation. It is recommended that you keep the default selections.
  6. On the "Adjusting your PATH environment" screen, select the option "Use Git from the Windows Command Prompt" to add Git to your system's PATH.
  7. Choose the desired line-ending conversion option. The default option is recommended for most users.
  8. Choose the desired terminal emulator used by Git Bash. The default option is recommended.
  9. Choose the default behavior for Git pull. The default option is recommended.
  10. Choose the default behavior for the Git credential manager. The default option is recommended.
  11. Click "Install" to start the installation process.
  12. Once the installation is complete, you can open the command prompt, Git Bash, or IDE terminal and verify the installation by running
git version

The return should show the current version of Git installed.

alt text


Appendix B: Common Git Commands

Setup

git config --global user.name <first.last> - Set the username for the local repository.

git config --global user.email <ADO Email> - Set the email address that will be associated with each history marker.

git config --global core.autocrlf false - Will resolve line break errors if your repository is stored in multiple operating systems.

git config --system core.longpaths true - Resolves path length errors.

git init - Initialize an existing directory as a Git repository.

git clone <url> - Retrieve an entire repository from a hosted location via a URL.

git remote add origin <URL> - Add the origin URL to the project config file.

Staging

git status - Show modified files in the working directory, staged for the next commit.

git diff - Diff of what is staged but not yet committed.

git commit -m <descriptive-message> - Commit your staged content as a new commit.

Branches

git branch - Lists all your branches. An * will appear next to the currently active branch.

git branch <branch-name> or git checkout -b <branch-name> - Creates a new branch at the current commit.

git log - Show the commit history for the currently active branch.

git diff <branchB>...<branchA> - Show the diff of what is in branchA that is not in branchB.

git push origin <branch> - Push local branch comits to the origin repository branch.

git rebase <branch> - Apply any commits of the current branch ahead of the specified ones.

git reset --hard <commit> - Clear the staging area and rewrite the working tree from the specified commit.

warning

This erases the current working tree.

Changes from Git

git rm <file> - Delete the file from the project and stage the removal for commit.

git mv <existing-path> <new-path> - Change an existing file path and stage the move for commit.

Temporary Commits

git stash - Save modified and staged changes without committing to the current branch.

git stash list - List the stack order of the stashed file changes.

git stash pop - Pull the top of the stash stack into the working tree.

git stash drop - Discard the changes from the top of the stash stack.


Revision History

RevisionDateNameDescription
1.0.06/13/2024Paul BurtInitial Implementation
2.0.09/9/2024Paul BurtNew screen shots. Updated instructions to align with new processes
2.0.110/16/2024Paul BurtAdded Common Git Commands Section.