Skip to content

Instantly share code, notes, and snippets.

@hanicker
Forked from hereswhatidid/archive-commit.bat
Created December 5, 2019 01:05
Show Gist options
  • Select an option

  • Save hanicker/2eb9c9466bfb372cc95ee2cb54ba253b to your computer and use it in GitHub Desktop.

Select an option

Save hanicker/2eb9c9466bfb372cc95ee2cb54ba253b to your computer and use it in GitHub Desktop.
Create a zip archive of a specific commit. The archive will be named deploy/deploy-COMMITID.zip.
setlocal enabledelayedexpansion
set var=%1
set output=
for /f "delims=" %%a in ('git diff-tree --no-commit-id --name-only -r %1^^') do ( set output=!output! "%%a" )
git archive -o update-%var:~0,7%.zip HEAD %output%
endlocal
#!/bin/sh
args=("$@")
git archive -o deploy/deploy-${args[1]:0:7}.zip HEAD $(git diff-tree --no-commit-id --name-only -r ${args[1]})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment