Skip to content

A tool for `git` repositories that creates a `ZIP` archive containing JUST the files representing the diff/delta between two related branches

License

Notifications You must be signed in to change notification settings

JanusMael/Git-ArchiveBranchDiffs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Git-ArchiveBranchDiffs

A tool for git repositories that creates a ZIP archive containing JUST the files representing the diff/delta between two related branches. This is similar to what GitHub provides in the changes view for pull request/PR reviews. Notably this tool supports comparing ANY TWO related branches and produces a self-contained archive which can be used offline and which DOES NOT require a PR to be created at all.

NOTE you must have git on your PATH when using this tool

Usage

If PowerShell Core is already installed or can be installed:

Execute the .ps1 file via pwsh and respond to the prompts for input parameters:

pwsh ./Git-ArchiveBranchDiffs.ps1

Execute the .ps1 file from an existing PowerShell and supply one or more of the parameters, respond to prompts for the remainder:

PS> ./Git-ArchiveBranchDiffs.ps1 -repositoryPath /c/myRepo -leftBranch master -rightBranch f/myBranch -outputDirectory /tmp

If Bash is installed and PowerShell Core is not installed:

Execute the .sh file via bash, PowerShell will be downloaded and will execute the .ps1 file, then respond to the prompts for input parameters:

sudo chmod +x ./Git-ArchiveBranchDiffs.sh
sudo bash ./Git-ArchiveBranchDiffs.sh

Input Parameters

Parameter Name Description
repositoryPath Specifies directory path to the root of a git repository
leftBranch Specifies the name of the branch to be the left-side of a diff comparison
rightBranch Specifies the name of the branch to be the right-side of a diff comparison
outputDirectory Specifies the directory path where the ZIP file will be created
archiveFileName [Optional] Specifies the name of the ZIP file that will be created

Features

  • No pull request/PR needs to exist to review the changes between two branches the same way you would normally review a pull request on GitHub

  • Files participating in the branch diff are pulled from either remote blobs or from the relevant local-only change(s) as appropriate

  • Placeholder Files are included in the output to ensure both left/right sides of the diff have representative file for each 'change'. Placeholders are included in the following change scenarios:

    Git Change Left Branch File Example Right Branch File Example
    Added /leftBranch/NewFile.cs-added (zero bytes) /rightBranch/NewFile.cs (new file, new content)
    Copied /leftBranch/OriginalFile.cs (original content) /rightBranch/OriginalFileCopied.cs (original content copied)
    Deleted /leftBranch/OriginalFile.cs (original content) /rightBranch/OriginalFile.cs-deleted (zero bytes)
    Modified /leftBranch/ModifiedFile.cs (original content) /rightBranch/ModifiedFile.cs (modified content)
    Renamed /leftBranch/RenameThisFile.cs-RXX (original content) /rightBranch/RenamedFile.cs (original file content, new file name)
    • For Rename the XX represents the Nth occurrence of a rename within the changeset / commit
        • e.g. R00 is the first rename, R01 is the second, and so on
    • Manifest - bookkeeping files and information generated by this tool are placed at the root of the archive (outside the directories representing each branch)
  • The output of this tool is suitable for comparison using a diff-tool (that supports directory diff) of your choice

    • This provides the ability to leverage additional features from the chosen tool, for example:
      • better syntax highlighting
      • detection of and suppression of 'unimportant' differences
      • treat suffixed placeholder files as directly comparable to their counterpart in the opposite branch
    • This also allows diff review to be done offline / disconnected

Directory Diff Tool Recommendations

About

A tool for `git` repositories that creates a `ZIP` archive containing JUST the files representing the diff/delta between two related branches

Resources

License

Stars

Watchers

Forks

Packages

No packages published