I'm using Git for version control and unlike SVN I have not come across an inherent means of performing an export of changed files between 2 revisions, branches or tags.
As an alternative I want to use the linux zip command and pass it a set of file names, however the file names are the result of another command git diff. Below is an example of what I am trying to achieve:
zip /home/myhome/releases/files.zip git diff --name-only -a 01-tag 00-tag
However the above does not work as I guess the 'zip' command sees the git operation as part of its command options.
Does someone know how I can make something like the above work?
Thanks
Syntax : $zip –m filename.zip file.txt 4. -r Option: To zip a directory recursively, use the -r option with the zip command and it will recursively zips the files in a directory. This option helps you to zip all the files present in the specified directory.
Using the zip command, create a ZIP archive of the newly created files. To create a ZIP archive, we simply use the command zip followed by the name we are giving the archive and then a list of the files we wish to include in the archive.
The Unix ZIP Command To create a ZIP file, go to the command line and type "zip" followed by the name of the ZIP file you want to create and a list of files to include. For example, you could type "zip example. zip folder1/file1 file2 folder2/file3" to create a ZIP file called "example.
You can compress directories and the corresponding sub-directories by using the -r flag. The -r flag will tell zip to traverse the entire directory recursively. To suppress the output from the compression process, use the -q for quiet mode. The command creates a zip archive of the specified files with no output.
You need to execute the git command in a sub-shell:
zip /home/myhome/releases/files.zip `git diff --name-only -a 01-tag 00-tag`
# another syntax (assuming bash):
zip /home/myhome/releases/files.zip $(git diff --name-only -a 01-tag 00-tag)
Another option is the xargs command:
git diff --name-only -a 01-tag 00-tag | xargs zip /home/myhome/releases/files.zip
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With