Last active
February 7, 2022 08:42
-
-
Save Taosif7/85f42ea81d893416672830872a8906e8 to your computer and use it in GitHub Desktop.
A batch script that zips the changed files from provided commit with folder stucture
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal EnableDelayedExpansion | |
REM ## Remove diff file if exists | |
if exist diff-filelist.txt del /f diff-filelist.txt | |
REM ## set output file name | |
set "outputFileName=%2" | |
IF "%~2" == "" ( SET "outputFileName=output.zip" ) | |
echo Zipping difference files from commits above %1 to %outputFileName% | |
REM ## Get file names | |
git diff --name-only %1 HEAD > diff-filelist.txt | |
REM Initialize the output file var | |
set "files=" | |
REM Catenate all files name lines that exists, in the same variable separated by " " | |
for /F "delims=" %%a in (diff-filelist.txt) do ( | |
IF exist "%%a" set "files=%%a !files!" | |
) | |
REM ## Make zip | |
tar.exe -a -c -f %outputFileName% %files% | |
REM ## Cleanup | |
del /f diff-filelist.txt | |
pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
Put in a folder whose path is accessible to your system, like windows/system32
Then run:
git-diff-zip HASH_OF_COMMIT_ABOVE_WHICH_DIFF_FILES_TO_BE_ZIPPED [output-file-name.zip]