Granular source member processing

<< Click to Display Table of Contents >>

Navigation:  IBM i Git Source Commands >

Granular source member processing

If you need more granular git repository processing such as diff-ing file versions and you're using a 5250 session, then you will want to define and use the PDM user defined options from the green screen.


If you're using GitHub, BitBucket, Azure Devops, GitLab, GitBucket or other internet based git server with a web browser, they will have ways for you to view source member changes.


Another option would be to install a PC, Mac or LInux based git client such as Tortoise, SourceTree or some other git client to review changes in the event an old member needs to be pulled from your repository and restored.


Restoring Old Source Member Version from a Repository

This section describes the  general process for restoring an old/previous version of a source member to a source physical file.


I generally think of this as the nuclear option for getting back a source member that has been altered beyond repair or code has been accidentally deleted from a source member.


You would generally restore an older version of a source member if:

You accidentally deleted the original source

You made a bunch of changes in the source member and deleted chunks of code you needed.

You wanted to restore just a small piece of code from an old source member or other source member.

You want to restore an older member to a library and use SEU option 55 to source compare in the classic development style instead of using diff or blame in git.


Before attempting to restore an older version of source:

Make sure you have committed and visually verified your latest source member changes for a member to its git repository via the GE PDM option or SRCTOGIT command.


Tip: Don't copy the source to a different source member in another library as that defeats the purpose of keeping all versioning under a single source member name.




Restore Source Member Version to Library From 5250:

Use the GL (Git Log) PDM option to view the log info on the source member commits or use the GB (Git Blame) option to determine which version your want to restore.


Then run the GC to prompt for the SRCGITCMD command option to check out a copy of the desired source member for a particular version (version source hash).


Paste the desired git version source version hash into the SRCHASH parameter and press enter to export and display the desired source member version copy.


Note: By default SRCGITCMD checks out a copy of the source member to a temporary source member that is created in source file QTEMP/TMPSOURCE, member name TMPSOURCE2.


Checkout to dest source file . . DESTFILE       TMPSOURCE    

  Library  . . . . . . . . . . .                  QTEMP      

Checkout to destination member   DESTMBR        TMPSOURCE2   

Add or replace member records  . DESTOPT        *NONE        


If you want to direct the checked out source member copy back to its original source physical file or to another development library just override the source library and file for the DESTFILE parameter and also specify the desired member name in the DESTMBR parameter.


Tip: Even though this option says check out, you're really just exporting a copy of the selected source member at the appropriate version from your git repository for working on it outside the repository structure.




Restore Source Member Version to Library From a PC:

Get a copy of the appropriate member version from the git repository to your PC (with VS Code or other PC based git client) or simply open the source member from your browser using GitHub, BitBucket or you chosen remote git repository software and view it in raw mode.


Now open the original source member for editing with SEU, RDI or VS Code.


Copy and paste to replace the entire source member or copy and paste selected chunks of source to the source member in the editor until all changes have been made.


Once the source member looks as you expect it to, save the changes in the editor back to the source member and immediately commit those changes to your git repository via the GE PDM option or SRCTOGIT CL command before making any more changes.



You have successfully restored your entire member or partial source member.