<< Click to Display Table of Contents >> Navigation: One Time Setup Commands > Hooking Up Git Repository Remotely to Github |
Description
As development teams are getting started using Git with IBM i, they may choose to simply store their Git repository in the IFS file system.
However many teams have employed Github or another remote provider to store their code and want to eventually start syncing changes with a Github repository so they can start using more of the Github features such as issues, etc.
The following steps will show how to hook up your local Git repository to a remote Github repository to push and sync changes to Github.
After hooking up to a remote repository there is then a minor change in your Edit, Save, Commit sequences and a modification to any PDM user commands or RDi user actions to incorporate doing a sync process (*COMMITSYNC) instead of just a commit ot the local IFS repository (*COMMIT).
By changing the use *COMMITSYNC, edits with SEU and RDI should always first sync with the remote repository to get the latest changes before editing.
**Note: The following steps are purely Git repository related and non-specific to the iForGit commands.
One time Github remote set up for remote repository
Log on to an IBM i 5250 session. You can also probably use an SSH session if desired.
Start QShell session
strqsh
Change to Git repository directory
cd /gitrepos/libname
Add remote origin for repository. This would typically be the URL to your remote repo along with Github user and password info.
git remote add origin https://githubuser:githubpass@github.com/reponame/repoproj.git
Ignore invalid SSL cert
git config http.sslVerify false
First time push sets the master
git push --set-upstream origin master -
**All other subsequent pushes to remote can just use: git push or *COMMITSYNC on all iForGit Commands
Changes in iForGit CL command usage.
When using LIBSRCEXP and exporting daily or one time initial source library changes and syncing to remote Github or other repository, use the *COMMITSYNC parm instead of *COMMIT.
LIBSRCEXP COMMITOPT(*COMMITSYNC)
When using SRCTOGIT to commit to IFS and then merge/sync to remote Github or other repo, use the *COMMITSYNC parm instead of *COMMIT. That should be the only change required.
SRCTOGIT COMMITOPT(*COMMITSYNC)
When using SRCFRMGIT to commit local changes and then merge/sync with remote repository and then upload to local source member, use the *COMMITSYNC parm instead of *COMMIT.
SRCFRMGIT COMMITOPT(*COMMITSYNC)
When using STRSEUGIT to merge/sync, edit and then re-commit local changes and then merge/sync with remote repository use the *COMMITSYNC parm instead of *COMMIT for both before and after edit commits. That should be the only change required.
STRSEUGIT COMMITBEF(*COMMITSYNC) COMMITAFT(*COMMITSYNC)
Another Alternative for Hookup to an Existing Github Repository
If desired you can set up an empty Github repository and then do the following steps to clone the repository to the IFS before using. Then you don't need to initialize the IFS repository directory before using to store source.
After cloning you should be able to start adding source members and committing them with the *COMMITSYNC option on the IForGit commands.
Change to Git repository directory
cd /gitrepos/libname
Clone existing repository
git -c http.sslVerify=false clone --recurse-submodules https://github.com/reponame/repoproj.git