This tutorial will take you through a very quick, very useful function in IBM Developer for z Systems when using Git: comparing differences in source members between your local repository (or working tree) and remote repositories (in this example: the main branch). This is a useful checking function to use before staging changes, and can be done very quickly and efficiently with little impact on development time. In the following steps, you will access source in your working tree, make a small change, then compare the difference between your working tree source and remote source in the main branch of the repository.
Prerequisites:
To take advantage of this feature, the user needs:
-
IBM Developer for zSystems (IDz) software, installed at version 16.0 or later and configured with a connection to a remote Git repository (populated with source and copied to your workstation)
-
Basic understanding of IDz navigation concepts, including the context menu (check out our no-charge IDz Remote Training options)
Estimated time:
This process should take about 5 minutes from start to finish, starting from your desktop.
Steps:
- Open IDz and specify a workspace. A workspace is a folder or directory on your computer that contains metadata (or data about data) around any customizations you have made to the IDz workbench.
- Navigate to the Git Repositories view in the upper-left of the workbench, and click the expand arrow to expand the repository.
- Expand your Working Tree and navigate to the folder containing the source file to be edited.
- Double-click the source file to open it up in the editor.
- With the source file open, make a small change. In this example, a line was added and a comment inserted on the new line.
- Use the Ctrl+S hotkey combination to save the file locally. Saving removes the asterisk next to the file name on the editor tab.
- Now that the edit has been made and the source file saved locally (on your machine), navigate back to the Git Repositories view, find the source file that was edited, right-click on it and choose Compare With > Branch, Tag, or Reference... from the context menu.
- The Compare dialog will appear. From here, expand Remote Tracking, then choose the branch you want to compare your local source file with, then choose Compare.
- The Source Compare facility will appear in the editor. In the lower half of the editor, the COBOL Source Compare will show the difference in the local and remote copies of your source file. In this example, it shows the new line and comment on the left side (local) and the remote copy without the new line and comment on the right (remote).
Upon completing these steps, you have learned how to quickly compare your locally-housed source files with a remote Git branch. This serves as a very light-weight, no-impact way to compare source files that you have changed or modified locally to their copies in Git before staging, giving you a level of control and safeguarding over the changes you push to the repository. Learn more about how to interact with Git inside of IDz v16 by attending the DevOps Distance Learning.