Skip to main content

导言

的实施 CODESYS Git 以 Git 中的工作和 Git 的术语为基础。安装完成后,菜单栏 CODESYS 将包括 Git 菜单中包含用于初始化 Git 项目和使用链接的 Git 存储库的命令。

有关中使用的一些术语,请参阅以下内容 CODESYS Git 帮忙然后在 CODESYS Git 用户界面。包括相应的标准 Git 命令。

使用 Git 的基础知识是先决条件。有关此的文档,请参阅(例如): Git BookAtlassian Git 存储桶

Git 存储库Git 项目存储 (“工作目录”、“工作树”)

对于纯粹的本地存储库来说 CODESYS Git 项目,我们在这里使用缩写的 “Git 存储库”。

The Git repository is located in the file system, in the "Git project storage", in the subdirectory .git. The objects of the project (<objecttype>_<ID>) which are managed in Git are located in the subdirectory project. The object files are located in a directory hierarchy which corresponds to the hierarchy of objects in the CODESYS project.

Git 项目存储还包含 Git 管理文件 .gitattribute.gitignore,以及 .apsession。这个文件 .apsession 用于控制的访问权限 CODESYS Git 存储库中的实例,被 Git 忽略。

可以在项目的 Git 项目存储路径中看到 Git 项目设置 观点。

The configuration settings, which are available in the .git/config file, can be modified in a CODESYS Git project via a configuration dialog. If there is no global config file in the local user directory from previous Git actions, then the user is prompted to create a configuration when initializing or cloning a project.

CODESYS项目目录

使用以下方法管理的项目 CODESYS Git 也总是存储在普通的 CODESYS 项目目录除了存储在 Git 项目存储中(双重数据管理)。

远程存储库:

看法: Git 遥控器

git remote

重要

确保您与远程服务器建立了安全连接。有关更多信息,请参阅: CODESYS Git 的安全性

远程存储库是托管在 Internet 上或网络上某个位置的项目的版本。您完全有可能使用 “远程” 存储库,该存储库实际上位于您当前正在使用的同一台计算机(主机)上。

远程存储库通常被命名为 origin

A CODESYS 已经在 Git 中在本地 Git 存储库中管理的项目可以链接到中的远程存储库 Git 遥控器 查看 (git remotegit remote add)。

只有在此之后,本地分支才能 “跟踪” 远程分支,并且才能为远程存储库(“上游”)中的本地分支创建等效分支。只有在那之后才能 ,以及 合并 命令用于在本地 Git 存储库和远程存储库之间交换/合并提交。

要使用远程存储库执行 Git 操作,通常需要凭据进行身份验证。它们保存在Windows的凭据管理器中。相同的凭据可以用于位于同一主机服务器上的所有远程存储库。有关更多信息,请参阅: 需要证书

本地分支机构、远程分支机构

看法:Git 分支

git remote

git branch

恰好有两种分支:“本地” 和 “远程”。本地分支可以 “跟踪” 一个远程分支。

当地分支机构:

Local branches are displayed in the Git Branches Local (<n>) view.

Git 存储库的本地默认分支(通常 master) 是在第一次提交后自动创建的。 CODESYS 项目是使用创建的 git clone,本地 “主” 分支会自动跟踪同名的远程分支。

本地分支也可以通过复制现有的本地分支或签出远程分支来创建。在最后一种情况下,最近创建的本地分支会自动跟踪远程分支。

远程分支机构:

Remote branches are displayed in the Git Branches Remote (<n>) view. They are the existing representatives in the Git repository of the respective branch with the same name in the remote repository.

远程分支机构仅在内部用作通过以下方式进行通信的 “中间位置” / 与远程存储库一起使用,不能由用户直接使用。

"Upstream"

命令在 Git 分支 当地的 看法

git branch --set-upstream-to <origin/remote-branch>

这个 上游 设置 操作导致在远程存储库(远程分支)中创建与本地分支相对应的分支。

"Tracking", "远程跟踪分支"

命令在 Git 分支 看法

git branch --track

git checkout

赛道分支 意味着在本地分支和远程分支之间创建链接。

默认案例:当地代表分支机构 master Git 存储库跟踪远程分支 origin/master 远程存储库的。

当本地分支跟踪远程分支时,可以通过以下方式与远程存储库交换提交

Alternatively, you could also use the Checkout command in the Git Branches Remote (<n>) view to create a local "tracking" branch, which is set as "current" branch at the same time, for an existing remote branch. The current branch is the one where new commits arrive.

Git index

看法: Git 状态

git status

The index is a Git-internal intermediate level between the working directory and the Git repository. It allows for selectively marking only a selection of changed objects for a commit. Not all changes have to be checked in as a commit.

Objects which are located in the Git index are visible in the Status & Staging view, in the Staged Changes section.

Resynchronization and reloading the project

Synchronization

The CODESYS project in CODESYS is resynchronized with the current state from the Git project storage after each Git operation which performs a change to the Git repository. These operations include the following:

  • 结账,以及 合并 分支机构(Git 分支 查看)

  • 丢弃所有更改回滚所有未暂存的更改状态和阶段 查看)

  • 通过解决冲突而发生的变化

的重新同步 CODESYS 项目的效果是项目是完全从存储库中重建的。没有尝试更新该项目。

你可以使用 从存储库重建项目 以明确启动重新同步。

另一方面,同步是应用从 CODESYS 项目存储到 Git 项目存储库中。每当在其中进行更改时,就会发生这种情况 CODESYS 项目。对项目进行更改时,仅应用这些更改。重新打开项目后,完整项目将再次应用到 Git 项目存储库并覆盖那里的状态

你可以使用 将项目与 Git 项目存储同步 用于显式启动同步的命令(默认情况下不在 Git 菜单中)。