Skip to content

Instantly share code, notes, and snippets.

@biplobice
Forked from ciases/git-zip-changed-files.md
Created March 31, 2022 03:33
Show Gist options
  • Save biplobice/f21e7a39a74c1515ca905aba75812033 to your computer and use it in GitHub Desktop.
Save biplobice/f21e7a39a74c1515ca905aba75812033 to your computer and use it in GitHub Desktop.
Git: zip changed files + diff

GIT: zip changed files + diff

Create zip archive with changed files

git archive -o update.zip HEAD $(git diff --name-only <starting SHA> HEAD)

or

git diff --name-only sha1 sha2 > list.txt
zip archive -@ < list.txt

Git diff between two commits

git diff sha1..sha2 > update.patch

Git Alias

Add git alias to .gitconfig:

[alias]
  zip-changed-files = "!f() { git diff --name-only \"$1\" \"$2\" > list.txt; zip update -@ < list.txt; rm list.txt; }; f"

Usage:

$ git zip-changed-files <sha1> <sha2>

Note! Use bash autocomplete. Do not type insane zip-changed-files manually :3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment