Git workflows for mainframe source
Moving mainframe source into Git means deciding how members become files, getting code pages right, and agreeing a branch and pull request workflow. Zowe and VS Code are where developers work; Git is the record; the pipeline builds what Git holds.
From library members to repository files
In a classic setup the truth lives in PDS libraries managed by a tool such as Endevor or ChangeMan. In a Git setup the truth lives in a repository and the libraries are built from it. The DevOps and CI/CD course (CI/CD) covers the pipeline itself; here we focus on the developer's side of the move.
| Library world | Git world | Things to decide |
|---|---|---|
Member PAYCALC in PAY.COBOL | cobol/PAYCALC.cbl | Folder per type; file extension; upper or lower case names |
Copybook PAYREC in PAY.COPYLIB | copybook/PAYREC.cpy | Where the build and the editor look for copybooks |
| Fixed 80-byte records | Lines of varying length | Strip trailing blanks or not; handle columns 73 to 80 |
| ISPF statistics (who, when) | Commit history | History before the move is usually not migrated in full |
Member names are at most eight characters and uppercase, which fits Git fine. The tricky parts are sequence numbers in columns 73 to 80, which change on every renumber and create noisy diffs, and trailing blanks, which some tools strip and others keep. Decide once, document it, and let the migration tool apply it consistently.
Code pages, again
Files in Git on a workstation are normally UTF-8. When files are checked out on z/OS with Git for z/OS, or uploaded through Zowe, they must become the right EBCDIC code page. .gitattributes declares which files are text and which encoding they use on z/OS, as shown in the DevOps course. Characters such as square brackets, the not sign, the vertical bar and currency symbols sit in different positions in different EBCDIC code pages, so a wrong code page often shows up as a broken COBOL or JCL statement rather than obvious garbage.
A simple branch and pull request flow
A pull request (GitHub, Bitbucket) or merge request (GitLab) is a request to merge your branch. Reviewers see the exact lines changed, the pipeline's build and test result, and any comments. It replaces the email or ticket where someone used to say 'please promote PAYCALC'.
- Create a branch named after the ticket, for example
feature/PAY-142-overtime. - Edit in VS Code. Use a personal build or a sandbox library so you do not overwrite a shared test load library.
- Commit small, clear changes and push the branch.
- Open a pull request; the pipeline compiles, links and runs tests.
- Address review comments, then merge. Deployment to test, QA and production follows the team's pipeline and approvals.
Where shared libraries fit
Two developers changing the same program on separate branches is normal in Git. It only works if each one builds into their own libraries, for example USER1.PAY142.LOAD, rather than all compiling into one shared test library where the last compile wins. Tools such as DBB and vendor build tools help by working out which programs a copybook change affects.
*.cblzos-working-tree-encoding=ibm-1047git-encoding=utf-8binaryHow this fits CI/CD
Zowe is the glue in many pipelines: a build agent runs the Zowe CLI to upload source, submit compile and bind jobs, and check return codes. Other pipelines run Git and the build directly in USS with DBB. Either way, the developer experience is the same: work in a branch, push, read the pipeline result, merge.
What file in a Git repository declares which files are text and their z/OS encoding?
Show a hint
It starts with a dot and lives in the repository root.
Show the solution
.gitattributes
Common mistakes
A wrong code page turns brackets and special characters into different characters. Round-trip a sample with special characters before migrating everything.
Parallel branches overwrite each other's load modules. Give each branch or developer its own build libraries.
Renumbering changes every line and hides the real change in the diff. Agree a convention, often removing or ignoring them.
What you will see at work
- Migration projects spend much of their effort on naming conventions, code pages and history decisions.
- Code review through pull requests replaces informal sign-off and gives auditors a clear record.
- Developers often keep ISPF for quick checks while doing day-to-day editing in VS Code from a Git clone.
Key terms
Check your understanding.
Take this lesson's quiz and save your progress. Free.