VPS business hosting starting at $29.95/24/7 premium technical support

How to generate a patch with edited files? How to zip latest committed changes only

zip archive.zip $(git diff-tree --no-commit-id --name-only -r latest-commit-id)

Reference: https://stackoverflow.com/a/42971972/2229148

sometimes you need all the files that were updated so you can patch an external app which doesnt uses same git project or many other scenarios in which we need a zip or tar of those files. Use the above command to do so

There is a smarter way also, if you want all the changes from last 5 commits, use the command like this:

zip archive.zip $(git diff-tree --no-commit-id --name-only -r HEAD~5 HEAD)

Author: Harshvardhan Malpani

PHP Developer based in New Delhi, India. Working as a freelance web developer providing server deployment, website development and maintenance services.

Leave a Reply

Your email address will not be published. Required fields are marked *