Skip to content

Instantly share code, notes, and snippets.

@berlotto
Created December 3, 2014 18:21
Show Gist options
  • Select an option

  • Save berlotto/42344c19a8f81d6d8f89 to your computer and use it in GitHub Desktop.

Select an option

Save berlotto/42344c19a8f81d6d8f89 to your computer and use it in GitHub Desktop.
getgitdiff - Script that archive the files from range of commits in git repo
#!/bin/bash
VERSION="0.1"
IDENT="latest"
if [ $# -lt 2 ] ; then
printf "getgidiff - created by [email protected]\n"
printf "Version:$VERSION\n"
printf "Usage:\n\tgetgitdiff {earlier-commit} {some-commit} [package-identification]\n"
exit 1;
fi
NOW="$(date +'%d-%m-%Y-%H-%M-%S')"
if [ -z "$3" ] ; then
IDENT="latest-$NOW"
else
IDENT="$3-$NOW"
fi
git diff --name-only $1 $2 | xargs -d'\n' git archive -o ../$IDENT.zip $2
echo "Done: file ../$IDENT.zip created."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment