View: Git Branches

Symbol:

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.

The view is refreshed.

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)

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.

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.

Merge

(git merge)

Clicking the button will execute the command directly. Alternatively, you could also set options for it. To do this, use the 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.

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 occur while merging, then they have to be resolved first. Depending on the case and the set merge Options, automated actions will run or manual actions are necessary. If a conflict cannot be resolved automatically, then this is indicated in the Git Status & Staging view. For conflict resolution in the first step, pay attention to the context menu commands provided in the Status & Staging view. Also see the Merge Conflicts help page.

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.

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).

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.

Pull

(git pull)

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.

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 copied 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 commit is compared with the last state of the object in the project storage and changes are displayed in the comparison view.

When two commits 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: : 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: : 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: : 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 on the local (tracking) branch with which its time is "behind" the remote branch