Skip to content

Instantly share code, notes, and snippets.

@emisjerry
Last active April 22, 2020 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emisjerry/4cdd266178be124eee2c71a3ef530f77 to your computer and use it in GitHub Desktop.
Save emisjerry/4cdd266178be124eee2c71a3ef530f77 to your computer and use it in GitHub Desktop.
git-export.bat: 產生Commit的檔案清單與相對路徑的壓縮檔;Windows適用
@echo off
chcp 65001
echo param1=%1, param2=%2
if "%1"=="" goto USAGE
del export.7z
if "%2%"=="" goto ONE_ARGUMENT
echo ***git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT %1 %2
for /f "usebackq tokens=*" %%A in (`git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT %1 %2`) do 7z a -sccUTF-8 export.7z "%%A"
git diff --name-status %1 %2 > export.txt
goto OPEN
:ONE_ARGUMENT
for /f "usebackq tokens=*" %%A in (`git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT %1~1 %1`) do 7z a -sccUTF-8 export.7z "%%A"
git diff --name-status %1~1 %1 > export.txt
goto OPEN
:USAGE
echo Usage: git-export First-Commit-SHA Second-Commit-SHA
echo Please change directory to a Git working folder first in Command Prompt.
:OPEN
start "7z" export.7z
start "txt" export.txt
:END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment