Git On IBMi ๐Ÿšค๐Ÿšค๐Ÿšค

Git On IBMi ๐Ÿšค๐Ÿšค๐Ÿšค

A simple guide for getting git in your i - Do try this at home.๐Ÿ“—

ยท

3 min read

Disclaimer: Git and GitHub are related but not the same. Git is software used for version control. GitHub is a company using Git software to provide GUI on git and various other features.

What is git?

Git is a free and open source distributed version control system designed to handle everything from small to huge projects with speed and efficiency. The Git feature that really makes it stand apart from nearly every other SCM out there is its branching model. More on git can be read here Git Docs

Git runs in the PASE environment in the Power system and can be used for version control by keeping sources in IFS and other stream files.

How to set up git on your machine?

  • You need the yum package manager first. Follow this
  • Using SSH login into your system ssh user@youstsrem.com and set the correct path if not done already via .profile PATH=/QOpenSys/pkgs/bin:$PATH && export PATH, this helps your shell in locating the open source binaries.
  • Preferentially use the BASH shell as it has a lot of friendly features bash into your terminal.
  • If you have yum then do a yum install git command to install git.

Get started with Git on IBMi ๐ŸคŸ

  • pwd to check the present working directory.
  • Use cd /path/to/direcory to native to the desired path.
  • mkdir dir-name command to create a new directory for version control, IFS is case sensitive in most places so let's pretend that to be the default feature to avoid confusion.
  • cd dir-name to get into the directory.
  • git init command will initialize the directory as a git repo, and you can see a new hidden file named .git is created. This file will have all the source control information so never ever delete this.
  • touch mypgm.rpgle command creates a new file mypgm.rpgle.
  • Make some changes in mypgm.rpgle and save those changes.
  • Do a git status command which tells you that there is a file name mypgm.rpgle which is not being tracked by git so you will have to tell git to track this file.
  • git add mypgm.rpgle adds mypgm.rpgle to the staging area(where changes will be tracked).
  • git add . command (notice the full stop) is to add all the untracked files in the working directory, this saves time if you have added a lot of files and they all need to be tracked.
  • git commit -m "my comments for code changes " command moves mypgm.rpgle to the local repository. The comments after -m in quotes are very important since they will tell you or other developers in the future why this commit was made, which is sort of documentation but in brief.
  • When a git initialization is done a branch named master is created by default which can be checked using git branch -a.

All commands summarised together - easy to copy and use

pwd
cd /path/to/directory
mkdir dir-name
cd dir-name
git init
touch mypgm.rpgle
git add mypgm.rpgle
git add .
git commit
git branch -a

๐Ÿฅณ There is more to git but these are the basic starting point. Usually, organizations also use source storage services like GitHub and BitBucket as central repositories to store their source and manage it easily. This will be covered in a later blog as first you should familiarize yourself with the initial steps first and get used to using git. There are tons of information already available on the web for git which can be referred for advanced learning.

image.png

In my next blog, I will be introducing a small toll to help in enabling native source control easily. Thank you for reading this far. ๐Ÿ˜€

Buy Me A Coffee

Did you find this article valuable?

Support Gajender Tyagi by becoming a sponsor. Any amount is appreciated!

ย