Skip to main content

View: Git Branches

Symbol: _git_icon_branch.png

Corresponding Git command: git branch

Function: The local Git branches are displayed and managed in the view. These can be branches which are already tracking a remote branch, or branches which exist purely locally and do not contain any link to a remote repository.

Call: Git → Branches menu

Requirement: At least one commit exists in the repository.

_git_icon_refresh.png

The view is refreshed.

_git_icon_branch.png Copy (git copy)

Opens the Create New Branch dialog to create a new local branch as a copy of the currently selected local branch (see above)

_git_icon_delete_branch.png Delete (git branch -D)

The selected branch is deleted, even if the branch has not yet been merged completely.

Note: The current branch cannot be deleted.

_git_icon_checkout_branch.png Checkout (git checkout)

As a result of the Checkout operation, the selected branch becomes the current branch. This means that the Git operations act on the contents of this branch, which are loaded into the local Git repository ("working directory") for this purpose.

A checkout is prevented by uncommitted changes.

When dealing with a remote branch – an entry under Remote (<n>) – the following options are possible:

  • A dialog opens with the message: This remote branch is already tracked by local "master" branch, which will be checked out instead. Branch name "origin/master".

    In this case, there is already a local remote branch (under Local (<n>)) which tracks the currently selected remote branch and can therefore Pull and Push with it. Then this local branch is loaded into the working directory for editing. It is possible that the checkout is denied at first, because of inconsistencies caused by local changes made directly in the working directory. With the Force option, these inconsistencies can be accepted initially and the checkout can still be performed.

  • Checking out this remote branch will create a corresponding local tracking branch. This name for the local branch is already used. The operation will most likely fail.

    In this case, there was not yet a local remote branch tracking the currently selected remote branch. CODESYS Git wants to create a local branch, but the name for it is already in use. With the Force option, the operation can still be forced.

    Attention: The existing branch will be overwritten by this.

  • There was no local remote branch yet. No tracking. This branch is now created and set as "current" and tracking is activated. This means that work will continue immediately on this branch.

_git_icon_merge_branch.png Merge

(git merge)

Clicking the button will execute the command directly. Alternatively, you could also set options for it. To do this, use the _cds_icon_arrow_down.png arrow key to select the Merge with options command. The Merge Branch dialog opens where you can select the Options which is valid for the current merge action.

Merging requires the name and email address of the user. This information is taken from the Git settings. If this is not possible, then a dialog prompt opens. The user name and email address can be changed in the Merge Branch dialog.

When you confirm the request (dialog prompt) whether or not you really want to commit, the commits of the currently selected branch are committed to the current branch. The current branch is the one whose status is now in the working directory. (check mark in the Current column)

If conflicts or relationship issues occur while merging, then they have to be resolved first. Depending on the case and the set merge options in the Branches view, automated actions will run or manual actions are necessary. If a conflict cannot be resolved automatically, then this is indicated in the Status & Staging view. For conflict resolution in the first step, pay attention to the context menu commands provided in the Status & Staging view.

As long as the merge operation has not been completed, the status info Merging is displayed in the header of the view as well as in the taskbar.

The Merge action requires the name and email address of the user. This information is taken from the Git Project Settings. If this is not possible, then a dialog prompt opens.

_git_icon_set_upstream_branch.png Upstream: Set/Clear

git push -u origin local-branch

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

Opens the Set upstream remote for Branch dialog

Here a branch corresponding to the local branch is created and the link with it set up on the linked remote repository (usually named "origin" and located on a server, for example).

_git_icon_track_branch.png Track branch

git branch --track

Opens the Track a remote branch dialog

Here the local branch can be linked with an available representative of a remote repository (remote branch). This allows for an exchange of commits (Git operations Pull and Push) between the local repository and remote repository.

_git_icon_pull.png Pull

(git pull)

_git_icon_pull.png Pull with options

The status of the tracked remote repository branch is fetched in the local branch (git fetch) and also merged with it (git merge). Requirement: The local branch tracks the remote branch of the remote repository.

The Pull action requires the name and email address of the user. This information is taken from the credentials stored on the computer. If this is not possible, then they are queried again in the Git pull <remote branch> dialog. For more information about the credentials for a remote repository, see: Credentials needed

The Pull with options command explicitly opens this dialog so that settings can be edited. If the Remember me option is enabled for the Name and Email credentials, then the settings from the dialog are saved in the Git configuration file .git/config in the local repository.

_git_icon_push.png Push

(git push)

If the selected branch is not a tracking branch, then the Push Branch dialog opens. Here you specify the remote branch to be merged into. The commits of the local branch are pushed to the corresponding branch in the remote repository.

If the selected branch is a tracking branch, then the action is performed immediately. No dialog opens.

Compare

The selected branch is compared with the last state of the project in the project storage and the differences are displayed in the comparison view.

When two branches are selected, they are compared.

Filter branches: Local|Remote

By clicking the Local (<n>) and/or Remote (<n>) buttons, the display of local branches and/or remote branches ("representatives" of the branches located in the remote repository) is enabled or disabled in the table.

Table

Current: standard icon: This is the local branch where work is currently being done. The Checkout operation is used to make a branch the current one. The working directory (Git repository) contains exact current the status of this branch.

Remote: standard icon: This is a "remote branch" located in the remote repository. The entry here is used as a representative of this branch (for example, origin/master as the representative branch of the remote repository).

Tracking: standard icon: The local branch tracks a remote branch, and is therefore linked with it for the exchange of commits using Git operations.

Name: Name of the branch

Canonical name: Unique name of the branch

Example: refs/heads/master

Remote: Name of the remote repository which the remote branch references (usually origin)

Upstream branch canonical name

Example: refs/heads/master

Tracked branch name: Name of the remote branch which is tracked

Example: origin/master

Tracked branch canonical name: Canonical name of the remote branch which is tracked. Example: remotes/origin/master

When a branch tracks a remote branch, the following information is relevant. Attention: This display is refreshed only when a Fetch command is executed:

Commits ahead: Number of commits on the local (tracking) branch with which its time is "ahead" of the remote branch

Commits behind: Number of commits which the local (tracking) branch is behind the remote branch.

Dialog: Create New Branch

Corresponding Git command: git branch --copy

Symbol: _git_icon_branch.png

Function: Create a new local branch.

Call: Copy command in the Local Branches view

Requirement: A local branch already exists.

Source branch

Name of the branch which is copied

New branch name

Input field for the new branch name

Force

standard icon: If there are uncommitted changes at the time of checkout, then by default the branches cannot be switched. However, this can be forced by means of the selected Force option.

Checkout

standard icon: The new branch is immediately checked out when it is created and is selected with a check mark as Current.

Dialog: Merge Branch

Symbol: _git_icon_merge_branch.png

Function: Set the merge options for the current merge operation. These options are predefined in the CODESYS options and can be changed for individual cases here in the Merge Branch dialog.

Call: Merge button in the Branches dialog; Merge with options command

Requirement: In the Git Branches view, a branch is selected which should be merged into the currently checked-out branch.

Branch to merge

The branch which is selected in the Git Branches view

User name and email address

When the text is expanded, the Name and Email can be changed.

The contents of the fields is preset from the Git settings user.name and user.email. If these Git settings are not available, then the user needs to specify the values.

Git Merge Options

Merge Conflict Strategy

For more information, see: Options: Git

Fast Forward Strategy

For more information, see: Options: Git

Commit On Success

If the merge was successful, then the resulting changes are committed automatically.