Zip latest committed changes only

Viewed 14362

Git has the very handy archive command which allows me to make a copy of a particular commit in a .zip archive like so:

git archive -o ../latest.zip some-commit

This will contain the entire working tree for that commit. Usually I just need the changed files since a previous release. Currently I use this to get those files into a zip:

git diff --name-only previous-commit latest-commit | zip ../changes.zip -@

This will however zip files from my working copy, which may have uncommitted changes. Is there some way to get only the changed files as they were committed directly into a zip?

6 Answers

try this, generate a patch_Ymd.zip from last commit:

git diff HEAD@{1} --name-only -z | xargs -0 git archive HEAD -o patch_$(date +'%Y%m%d').zip --

Related