Git operations in DevOps Test Integrations and APIs

You can work with your project files that are in a Git repository from IBM® DevOps Test Integrations and APIs (Test Integrations and APIs) and perform Git operations such as checking out files from the remote repository and committing changes in the local repository to the remote repository. You can also set up the preferences in Test Integrations and APIs for Git.

You can perform the following Git operations in Test Integrations and APIs:
Note: The Git operations are enabled in the Test Integrations and APIs UI only after you open the project contained in the local repository.

Checking the status of files in repositories

You can visually ascertain the connectivity between Test Integrations and APIs and your project in a Git repository and check the status of the files in that project on the repositories.

Before you can check the status of the project files in a Git repository, certain tasks must be completed:
  • You must have set up the Git repositories.
  • The project files must exist in the local repository.
  1. Open your project after you start Test Integrations and APIs, and then click Browse to navigate to the project in the local repository.
  2. Look at the status bar for the icons that indicate connectivity to the Git repository.
    Use the following table to interpret the icons displayed.

    Icon

    Description

    image of the icon

    No Git repository exists that contains the project opened in Test Integrations and APIs. The project files exist only in the local repository.

    image of the icon

    The Git repository exists but is not connected.

    image of the icon

    The Git repository exists and is connected.

  3. Check for the status of the files in the project contained in the local and remote Git repositories from the Status bar.
    Use the following table to interpret the status displayed.

    Icon

    Description

    image of the icon

    The master branch in the Git repository exists but is not connected.

    image of the icon

    The master branch in the Git repository exists and is connected.

    image of the icon

    The master branch in the Git repository exists and is connected. The status of the files in the repositories is shown with numbers prefixed with colored arrows.

    The green colored arrow (image green arrow) indicates the local repository and the red colored arrow (image of red arrow) indicates the remote Git repository. Both the green and red arrows together (image of both arrows together.) indicate a file conflict state between the files in the local and files in the remote repositories.

    image of red arrow and number next to it

    The number along with the green colored arrow indicates the files on the local repository that are modified with respect to the same files on the remote Git repository.

    image of green arrow and number next to it

    The number along with the red colored arrow indicates the files on the remote Git repository that are modified with respect to the same files on the local repository.

    image of both red and green arrows and number next to it

    The number along with both the green and red colored arrows indicates the files with a potential conflict.

    A conflict is displayed when the same file has changes made by you in the local repository and has also been changed by someone else on the remote repository. You must resolve this conflict by either merging the changes or rejecting the changes in the remote version. You must resolve this conflict outside of Test Integrations and APIs by using the Git commands or any other method you prefer.

  4. Hover your cursor over the Git icon and numbers to view the location of the Git repository connected to Test Integrations and APIs displayed as a tooltip:
    image showing the tooltip with location of repository.
  5. Click the area with the Git icon and numbers, to view the details of the files in the repositories and files that are in conflict.
    The Git Information window is displayed as shown in the following sample image.
    image showing the Git information window.

    The details of the files in the local repository that are modified with respect to the files in the remote repository are shown in the following table.

    Status

    Description

    Local

    The details of the files in the local repository.

    Ahead

    The details of the files in the local repository that are modified with respect to their version on the remote Git repository. The files in the local repository have changes that are not committed or pushed to the remote repository.

    Behind

    The details of the files in the remote Git repository that are modified with respect to their version on the local Git repository. The files in the remote repository have changes that are not yet pulled into the local repository.

Checking status in the Test Factory or Architecture School perspective views
  1. Check for the status of the files in the project contained in the local and remote Git repositories by looking at the icons prefixed to the test asset in the Test Factory or Architecture School perspective views.
    Use the following table to interpret the displayed icon prefixed to the test asset.

    Icon

    Description

    image of the icon

    The file in the local repository that is changed from the file in the remote Git repository.

    For example, the icon displayed for a changed file in the Test Factory perspective is image of the icon.

    image of the icon

    The file in the remote Git repository that is changed from the file in the local repository.

    For example, the icon displayed for a changed file in the Test Factory perspective is image of the icon.

    image of the icon

    The file is in conflict means that the file has changes made by you in the local repository and the same file has also been changed by someone else on the remote repository.

    For example, the icon displayed for a changed file in the Test Factory perspective is image of the icon.

Updating a project in the repository

You can check out the project files from the remote Git repository to your local repository by using the UI option in Test Integrations and APIs. You can use this option when you want to use the latest version of the project files from the remote Git repository. This option performs a Git checkout of those files that have a conflict and does a Git fetch for the other files.

Before you can update the files in a project in a Git repository, certain tasks must be completed:
  • You must have set up the Git repositories.
  • The project files must exist in the local repository.
  • You must have opened the project from the local repository.
Tip: You can check whether the repository is connected by looking at the Git icon image of the icon displayed in the Status bar.
  1. From the Menu, click Tools > Update Project.

    The Update Project window is displayed.

  2. Select your action from the following options:
    If... Then... Result
    There are no new commits to the remote repository. Click OK. No files are updated in the local repository from the remote repository.
    There are changed or new files committed to the remote repository. Click OK. The files are updated in the local repository with the files from the remote repository.
    Note: The open editors in your project are refreshed and reflect the updated files in the local repository.
    There are files in a conflict state between the local and remote repositories. Click OK. The files in the local repository that are in the conflict state are overwritten by the files from the remote repository.
    Notes:
    • The uncommitted changes in your project files are discarded.
    • The open editors in your project are refreshed and reflect the updated files in the local repository.
    Perform the following steps if you want to retain the changes in your local version of the file and merge the changes from the remote file version:
    1. Click Cancel to close the Update Project window.
    2. Perform the merge operation outside of Test Integrations and APIs by using your preferred Git method.
    After you merge the files, both the local and the remote repositories contain the same version of the files.
You have achieved either of the following results:
  • Updated the project files in your local repository with the version from the remote Git repository.
  • Retained your changes in the files by resolving the merge conflict state by using your preferred Git method.

Delivering changes to the project in the Git repository

After you have made changes to the project files, you can deliver the changes in your local Git repository by using the UI option in Test Integrations and APIs to the project in the remote Git repository. This option performs the Git add, Git commit, and Git push operations on the files in that project to the remote Git repository.

You must have completed the following tasks:
  • Set up the Git repositories.
  • Ensured that the project files exist in the local repository.
  • Opened the project from the local repository.
  • Made changes in the project for the files to show as changed in the Test Integrations and APIs UI.
Tip: You can check whether the repository is connected by looking at the Git icon image of the icon displayed in the Status bar.
Before you start working on your project files, you can check the Status bar for files on the remote repository and decide your action:
  • If no new files are shown as present in the remote repository, you can continue with working on your project.
  • If new files are shown as present in the remote repository, then you must perform the Update Project action to fetch the latest files from the remote repository.

After you complete making changes to your project files and you want to commit your files to the remote repository, you can use the Deliver changes option.

While you worked on your project, someone else too worked on the same files and committed their changes to the remote repository. When you attempt to deliver your changes then a conflict state is displayed. You can then perform any of the following actions listed in the following table:
The following table provides information about the choices that you have when delivering changes.
If... Then... Result...

You want to merge the changes in the files.

You must perform the merge operation outside of Test Integrations and APIs by using your preferred Git method.

Files in the local and remote repositories are merged.

The changes that you made in your project files are retained in the merged files.

You want to use the files in the remote repository and discard the changes you made in your project files.

Perform the following actions:
  1. Use the Update Project option to check out the files from the remote repository.
  2. Make changes to your project files.
  3. Use the Deliver changes option to commit your files to the remote repository.

The changes in your project files are discarded and files in the local repository are updated with the files from the remote repository.

After you deliver the changes, files in the remote repository are updated and both repositories have the same files.

  1. To use the Menu option, complete the following steps:
    1. From the Menu, click Tools > Deliver changes.
      The changed files are listed as selected in the Deliver changes dialog box.
      Note: Using the Menu option to deliver changes selects all the resources that have changed in the project. You can clear the selected resources by using the Clear All Image of the select all icon icon or by selecting the check box of the resource that you want to clear. You can select the resources that you want by selecting the check box or use the Select All Image of the select all icon icon to select all the resources listed.
    2. In the Deliver changes dialog, enter text in the Commit Message field.
    3. Click OK.
  2. To use the Git options in the Logical View (Tree View) of the Architecture School perspective, complete the following steps:
    1. Open the Logical View in the Architecture School perspective and select the tree view.
    2. Select the test asset that contains the changed file, right-click, and then click Deliver changes.
      You can identify the changed file if it is prefixed with the image of the icon icon.
      Image of the Git menu options in the logical view.

      The changed files are listed as selected in the Deliver changes dialog.
      Note: Using the Git menu option to deliver changes selects all the resources under that test asset that you selected. You can clear the selected resources by using the Clear All Image of the select all icon icon or by selecting the check box of the resource that you want to clear. You can select the resources that you want by selecting the check box or use the Select All Image of the select all icon icon to select all the resources listed.
    3. In the Deliver changes dialog, enter text in the Commit Message field.
    4. Click OK.
  3. To use the Git options in the Test Factory perspective, complete the following steps:
    1. Select the test asset that contains the changed file, right-click, and then click Deliver changes.
      You can identify the changed file if it is prefixed with the image of the icon icon.
      Image of the Git menu options in the test factory view.

      The changed files are listed as selected in the Deliver changes dialog.
      Note: Using the Git menu option to deliver changes selects all the resources under that test asset that you selected. You can clear the selected resources by using the Clear All Image of the select all icon icon or by selecting the check box of the resource that you want to clear. You can select the resources that you want by selecting the check box or use the Select All Image of the select all icon icon to select all the resources listed.
    2. In the Deliver changes dialog, enter text in the Commit Message field.
    3. Click OK.
  4. To use the Git options in the Physical View of the Architecture School perspective, complete the following steps:
    1. Open the Physical View, select the test asset, right-click, and then click Deliver changes.
      You can identify the changed file if it is prefixed with the image of the icon icon.
      Image of the Git options in the physical view.

      The changed files are listed as selected in the Deliver changes dialog.
      Note: Using the Git menu option to deliver changes selects all the resources under that test asset that you selected. You can clear the selected resources by using the Clear All Image of the select all icon icon or by selecting the check box of the resource that you want to clear. You can select the resources that you want by selecting the check box or use the Select All Image of the select all icon icon to select all the resources listed.
    2. In the Deliver changes dialog, enter text in the Commit Message field.
    3. Click OK.

The changes that you made in your project files in Test Integrations and APIs are pushed to the project in the remote Git repository.

Undoing changes in the local repository

You can check out the project files from the remote Git repository to your local repository by using the UI options in Test Integrations and APIs. Use this option when you have uncommitted changes in the project files on your local Git repository and you want to ignore those and reload the project using files from the remote Git repository.

You must have completed the following tasks:
  • Set up the Git repositories.
  • Ensured that the project files exist in the local repository.
  • Opened the project from the local repository.
  • Made changes in the project for the files to show as changed in the Test Integrations and APIs UI.
Tip: You can check whether the repository is connected by looking at the Git icon image of the icon displayed in the Status bar.

You can undo changes in your project files in the local repository by checking out the files from the remote Git repository. When you perform the Undo changes action in your project, the open editors in your project are refreshed and the files in the local repository are updated. All files that you had changed are discarded and are replaced with the files from the remote repository.

  1. To use the Menu option, complete the following steps:
    1. From the Menu, click Tools > Undo Changes.
      The changed files in the local repository are listed as selected in the Undo changes window.
      Note: Using the Menu option to undo changes selects all the resources that have changed in the project. You can clear the selected resources by using the Clear All Image of the select all icon icon or by selecting the check box of the resource that you want to clear. You can select the resources that you want by selecting the check box or use the Select All Image of the select all icon icon to select all the resources listed.
    2. In the Undo changes window, click OK.
  2. To use the Git options in the Logical View (tree view) of the Architecture School perspective, complete the following steps:
    1. Open the Logical View in the Architecture School perspective and select the tree view.
    2. In the tree view, identify the files that are changed and uncommitted files in the project, which are prefixed with the image of the icon icon.
      For example, if you have created a copy of a test and have not yet checked in the project files into the remote Git repository, the changed asset is displayed with the prefixed icon.
      image showing the tree view in the Logical View with the changed file

    3. Select the test asset that contains the changed file, right-click, and then click Undo changes.
      The changed files are listed as selected in the Undo changes window.
      Note: Using the Git menu option to undo changes selects only the resources under that test asset that you selected. You can clear the selected resources by using the Clear All Image of the select all icon icon or by selecting the check box of the resource that you want to clear. You can select the resources that you want by selecting the check box or use the Select All Image of the select all icon icon to select all the resources listed.
    4. In the Undo changes window, click OK.
  3. To use the Git options in the Test Factory perspective, complete the following steps:
    1. In the Test Factory perspective, identify the files that are changed and uncommitted files in the project, which are prefixed with the image of the icon icon.
      For example, if you have created a copy of a test and have not yet checked in the project files into the remote Git repository, the changed asset is displayed with the prefixed icon.
      image showing the test factory view with the changed file

    2. Select the test asset that contains the changed file, right-click, and then click Undo changes.
      The changed files are listed as selected in the Undo changes window.
      Note: Using the Git menu option to undo changes selects only the files under that test asset that you selected. You can clear the selected resources by using the Clear All Image of the select all icon icon or by selecting the check box of the resource that you want to clear. You can select the resources that you want by selecting the check box or use the Select All Image of the select all icon icon to select all the resources listed.
    3. In the Undo changes window, click OK.
  4. To use the Git options in the Physical View of the Architecture School perspective, complete the following steps:
    1. Open the Physical View, identify the files that are changed and uncommitted files in the project, which are prefixed with the Image of the icon. icon.

      Image of the Git options in the physical view.

    2. Select the test asset that contains the changed file, right-click, and then click Undo changes.
      The changed files are listed as selected in the Undo changes window.
      Note: Using the Git menu option to undo changes selects only the files under that test asset that you selected. You can clear the selected resources by using the Clear All Image of the select all icon icon or by selecting the check box of the resource that you want to clear. You can select the resources that you want by selecting the check box or use the Select All Image of the select all icon icon to select all the resources listed.
    3. In the Undo changes window, click OK.

The changes that you made in your local project files in Test Integrations and APIs are discarded and the latest version from the remote Git repository is checked out into the local repository.

Setting preferences for Git

You can specify the Git directory and workspace when you are setting Git in the bare mode or specify your credentials to access the remote Git repository by using the Preferences option in Test Integrations and APIs. You can also configure the Secure Shell (SSH) settings or the name of the remote repository.

  1. From the Menu, click Project > Preferences.
  2. Click Git in the Preferences window.

    The git preferences window.

  3. Set up the Git repository in the bare mode by completing the following steps:
    1. Select the Enable bare mode check box.
    2. Enter the location of the Git repository that you want to set up as a bare directory. Alternatively, click Browse and navigate to the directory to select it.
      Note: You can use this option if you want to set up a bare Git directory without the project files. To set up a local repository, you must load the project files into the local repository by using your preferred method in Git before you open the project in Test Integrations and APIs.
    3. Enter the location that you want to use as the working directory or click Browse to navigate to the location.
  4. Set up your user credentials to enable access to the remote Git repository from Test Integrations and APIs by completing the following steps:
    1. Select the Git credentials check box.
    2. Enter your user name that you set for the remote Git repository.
    3. Enter the password for the user name.
  5. Set up the SSH communication between the client that hosts Test Integrations and APIs and the server that hosts Git by completing the following steps:
    1. Select the SSH settings check box.
    2. Enter the location of the Private Key that must be used to authenticate the client with the remote server. Alternatively, click Browse, navigate to the directory, and then select the Private Key.
    3. Enter the passphrase configured for the Private Key in the Passphrase field.
  6. Enter the name that you want to use for the remote repository in the Remote origin field.

    If you do not provide a name, the default name considered is origin.

  7. Click Apply, and then click OK to apply the preferences.