Products Resources Support About Us

Installing git for z/OS

Installing git for z/OS can be a challenge for systems programmers without much Unix System Services (USS) experience. This article provides relatively detailed instructions, as well as a script that can help automate the process.

Before starting, you’ll need to go to the Rocket Open Source Languages and Tools for z/OS page and create a (free) Rocket Community account, if you don’t already have one. That will enable you to access all of the open source tool downloads.

These instructions assume that:

  • You will first download the installation files to a Windows system.
  • You know how to transfer binary files from a Windows system to a z/OS Unix file system.

Here we go!

  • Create a folder on Windows into which you will save the installation files before transferring them to z/OS.

  • Download the 4 necessary files off the Rocket download site, for gzip, bash, git and perl. The file names (at the time of this posting) should be:

    • gzip-1.6-edc_b0005.160229.tar
    • bash-4.3_b018.170518.tar.gz
    • git-2.3.5_b013.161229.tar.gz
    • perl-5.24.0_b005.170601.tar.gz
  • In the same folder, save this file attachment: helper.tar (31.5 KB)

  • Create a directory on USS where you will put all the installation files. It can be a subdirectory of your home directory.

  • Binary transfer all 5 of the files from Windows to the USS directory.

  • cd into the directory on USS that contains the installation files.

  • Untar the helper script, using the following command. This will create the file

    tar -xoUXf helper.tar

  • By default, will install the software into the directory that contains the installation files. If you want to install elsewhere, edit and change the value of INSTALL_DIR at the top of the script.

  • Run, like this:


This will install all the software and create some additional scripts:


To set up the environment to use git you must ‘source’ You do that with this command:

. ./

Look very carefully at that command line – It’s using the “dot” command to cause bash to read the contents of the file You are must not run the script; you must source it.

At this point you can use git. If you just type git you should get a help message.

Once you are satisfied that git is working properly, you can delete the installation files, using ./


Here’s the source code for the script contained in helper.tar.

#! /bin/sh

# If you want to install the tools in a directory other than 
# the download directory, change INSTALL_DIR to point to it.

if [[ ! -d $INSTALL_DIR ]] ; then
  echo making $INSTALL_DIR
  mkdir $INSTALL_DIR
  if [[ ! -d $INSTALL_DIR ]] ; then
    echo unable to create installation directory $INSTALL_DIR
    exit 1;

unpack() {
  if [[ ! -f $distfile ]] ; then
    echo "distribution file $distfile does not exist"
    return 1
  if [[ ! -d $targetdir ]] ; then
    echo "$targetdir is not a directory"
    return 1

  $INSTALL_DIR/bin/gzip -c -d <$distfile | tar -C $targetdir -xoUXf -
  if [[ $? != 0 ]] ; then
    echo "unpacking $distfile into $targetdir failed"
    return 1

  return 0;

echo "installing gzip, bash, perl and git into $INSTALL_DIR"


# Install gzip. It is NOT compressed.
tar -C $INSTALL_DIR -xoUXf $gzipdist

if [[ ! -f $INSTALL_DIR/bin/gzip ]] ; then
  echo "installation failed for gzip"
  exit 1
  echo "gzip installed"

# Unpack the files for bash, git and perl

unpack $bashdist $INSTALL_DIR
unpack $gitdist $INSTALL_DIR
unpack $perldist $INSTALL_DIR

# Make sure that the permissions are correct
find $INSTALL_DIR/lib -type f -exec chmod 644 {} \; 
find $INSTALL_DIR/lib -type f -name '*.so' -exec chmod 755 {} \; 

# Update with the install location
cat > <<EOF 
# These lines can be added to the user's ~/.profile or they can be sourced as needed.

# Set the various PATHS to find the code for bash, git and perl
export PERL5LIB=$INSTALL_DIR/lib/perl5:\$PERL5LIB
export LIBPATH=$INSTALL_DIR/lib/perl5/5.24.0/os390/CORE:\$LIBPATH

export GIT_SHELL=$INSTALL_DIR/bin/bash
export GIT_EXEC_PATH=$INSTALL_DIR/libexec/git-core
export GIT_TEMPLATE_DIR=$INSTALL_DIR/share/git-core/templates

# Set up the enhanced ASCII support flags
export _TAG_REDIR_ERR=txt
export _TAG_REDIR_IN=txt
export _TAG_REDIR_OUT=txt

# create the uninstall script
cat > <<EOF
#! /bin/sh
rm -rf bin lib libexec man share  README
chmod +x

cat > <<EOF
#! /bin/sh
# remove the download files after installation
rm -f $gzipdist $bashdist $gitdist $perldist
chmod +x

# Run the perl path change script