gitで一世代前との差分ファイルを抽出する

Windowsバッチ

@echo off
FOR /F "usebackq" %%t IN (`CD`) DO SET HERE=%%t
mkdir ..\diff
git diff --name-only HEAD HEAD~1 > ..\diff\tmp.txt
if not %ERRORLEVEL% == 0 goto error
for /f "tokens=*" %%A in (..\diff\tmp.txt) do call :d1 %%A
goto end

:d1
set raw=%1
set filepath=%raw:/=\%
echo F | xcopy "%filepath%" "..\diff\%filepath%" /E /V /H /R /Y
if not %ERRORLEVEL% == 0 goto error
goto out

:error
:end
:out

Linuxコマンド

git archive --format=zip --prefix=archive/ HEAD `git diff --name-only HEAD HEAD~1` -o archive.zip