Search code examples
bitbucketgit-bashgit-gui

How to use Git Bash to create a zip file between commits ignoring deleted files


I use Bitbucket and I am looking to create a zip file between commits so that I can supply only the changed files to a client. I currently use:

git archive --output=changes.zip HEAD $(git diff --name-only SHA1 SHA2)

Which works absolutely fine if all the files are there. However if there is a file that has been deleted between commits I get the error:

fatal: pathspec 'FILENAME' did not match any files

What is the best way of doing this, can you do it in Bitbucket, Git Gui or Git Bash?


Solution

  • Looks like the option diff-filter with lowercase d excludes deleted files:

    git archive --output=changes.zip HEAD $(git diff --name-only --diff-filter=d SHA1 SHA2)