Products Resources Support About Us

Sharing a repo between z/OS and Linux

Here’s a sequence that I have used successfully to set up a repo that is shared between Linux and z/OS. The initial set up is a bit clumsy, but once complete, it’s then easy to push and pull from either platform.

  • Set up an ssh key pair that enables you to ssh from z/OS to Linux without a password.

The next set of commands are run on the Linux host.

  • Create a bare repository on Linux.

    [myuserid@linuxhost ~]$ git init myrepo.git --bare
    Initialized empty Git repository in /home/myuserid/myrepo.git/
    [myuserid@linuxhost ~]$

  • Clone the bare repo on Linux.

    [myuserid@linuxhost ~]$ git clone myrepo.git myrepo
    Initialized empty Git repository in /home/myuserid/myrepo/.git/
    warning: You appear to have cloned an empty repository.
    [myuserid@linuxhost ~]$

  • cd into the repo, then create, add and commit the .gitignore and .gitattribute files.

    [myuserid@linuxhost ~]$ cd myrepo
    [myuserid@linuxhost myrepo]$ cat >.gitattributes <<EOF
    > *.md git-encoding=iso8859-1 working-tree-encoding=ibm-1047
    > *.[hc] git-encoding=iso8859-1 working-tree-encoding=ibm-1047
    > EOF
    [myuserid@linuxhost myrepo]$ cat >.gitignore <<EOF
    > *.o
    > EOF
    [myuserid@linuxhost myrepo]$ git add .gitignore .gitattributes
    [myuserid@linuxhost myrepo]$ git commit -m “add git attribute and ignore files”
    [master (root-commit) ded1dea] add git attribute and ignore files
    2 files changed, 3 insertions(+), 0 deletions(-)
    create mode 100644 .gitattributes
    create mode 100644 .gitignore
    [myuserid@linuxhost myrepo]$

  • Push to the bare repository.

    [myuserid@linuxhost myrepo]$ git push origin master
    Counting objects: 4, done.
    Delta compression using up to 4 threads.
    Compressing objects: 100% (3/3), done.
    Writing objects: 100% (4/4), 343 bytes, done.
    Total 4 (delta 0), reused 0 (delta 0)
    Unpacking objects: 100% (4/4), done.
    To /home/myuserid/myrepo.git

    • [new branch] master -> master
      [myuserid@linuxhost myrepo]$

The next set of commands are run on z/OS.

  • Clone the repository.

    bash-2.03$ git clone -n ssh://myuserid@lnxrhkbm/home/myuserid/myrepo.git myrepo
    Cloning into ‘myrepo’…
    bash-2.03$

  • cd into the repository and checkout master.

    bash-2.03$ cd myrepo
    bash-2.03$ git checkout master
    Already on 'master’
    Your branch is up-to-date with ‘origin/master’.
    bash-2.03$ ls -alT
    total 64
    drwxr-xr-x 3 MYID PDUSER 8192 Dec 6 10:42 .
    drwxr-xr-x 3 MYID PDUSER 8192 Dec 6 10:41 …
    drwxr-xr-x 8 MYID PDUSER 8192 Dec 6 10:42 .git
    t ISO8859-1 T=on -rw-r–r-- 1 MYID PDUSER 124 Dec 6 10:42 .gitattributes
    t ISO8859-1 T=on -rw-r–r-- 1 MYID PDUSER 4 Dec 6 10:42 .gitignore
    bash-2.03$

  • Create a new file and tag it as EBCDIC

    bash-2.03$ cat >README.md <<EOF
    > This is a test repo
    > EOF
    bash-2.03$ chtag -tc1047 README.md
    bash-2.03$ git status
    On branch master
    Your branch is up-to-date with ‘origin/master’.
    Untracked files:
    (use “git add …” to include in what will be committed)

          README.md
    

    nothing added to commit but untracked files present (use “git add” to track)
    bash-2.03$ git check-attr -a README.md
    README.md: git-encoding: iso8859-1
    README.md: working-tree-encoding: ibm-1047
    bash-2.03$

  • Add the new file, commit it, and push it to the origin.

    bash-2.03$ git add README.md
    bash-2.03$ git commit -m “add a README”
    [master 3453302] add a README
    1 file changed, 1 insertion(+)
    create mode 100644 README.md
    bash-2.03$ git push origin master
    To ssh://myuserid@lnxrhkbm/home/myuserid/myrepo.git
    ded1dea…3453302 master -> master
    bash-2.03$

The final set of commands is run on Linux.

  • Pull from the origin and verify that the new README file is properly encoded.

    [myuserid@linuxhost myrepo]$ git pull
    remote: Counting objects: 4, done.
    remote: Compressing objects: 100% (2/2), done.
    remote: Total 3 (delta 0), reused 0 (delta 0)
    Unpacking objects: 100% (3/3), done.
    From /home/myuserid/myrepo
    ded1dea…3453302 master -> origin/master
    Updating ded1dea…3453302
    Fast-forward
    README.md | 1 +
    1 files changed, 1 insertions(+), 0 deletions(-)
    create mode 100644 README.md
    [myuserid@linuxhost myrepo]$ cat README.md
    This is a test repo
    [myuserid@linuxhost myrepo]$