Skip to content

Instantly share code, notes, and snippets.

@svdmitrij
Last active December 13, 2018 13:21
Show Gist options
  • Save svdmitrij/66170c6b9714bf0a7e60 to your computer and use it in GitHub Desktop.
Save svdmitrij/66170c6b9714bf0a7e60 to your computer and use it in GitHub Desktop.
Create archive from diff between two commits
#!/usr/bin/env bash
firstCommit=$1
secondCommit=$2
if [[ -z $firstCommit || -z secondCommit ]]; then
echo "Usage: $0 first_commit_sha second_commit_sha"
fi
git archive --format=tar.gz -o changes.tgz "$secondCommit" $(git diff --name-only "$firstCommit")
@svdmitrij
Copy link
Author

svdmitrij commented Nov 7, 2018

Install: put the script into ~/bin (or any directory in $PATH), chmod +x ~/bin/git_archive.sh
Usage: git_archive.sh first_sha second_sha
second_sha - newer commit
first_sha - older commit
The archive is changes.tgz in current directory.

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