Search code examples
gitgithooksgit-pushgit-commit

List of files in a git push using git archive


Is there a way to get only those files that are in a git push, onto a separate folder, using git archive?

I tried the below solution

git archive --format zip --output /full/path/to/zipfile.zip ${commitid}

but I can get the entire repository content.

I am basically looking for files that are being committed and pushed at the server side(pre-receive).


Solution

  • The following command prepares an archive of all the files modified by the commit specified :

    $ git diff-tree -z --no-commit-id --name-only -r <commit-id> | xargs -0 git archive -o list.zip HEAD: