Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems using git diff to create file list for deploy

I want to use something like the following command to create a tarball to deploy:

tar cjvf ~/deploy.tar.bz2 `git diff --name-only 0abc 1def`

The inner git diff command produces a list of files with relative including the relative path when i run it separately.

I'm running into two problems though, I need to be able to auto escape spaces in the output, so tar doesn't complain about files containing spaces and when the tar does get created, all the files have a duplicate 'hidden file' preceded by a '.' that don't show up with ls -al. These are OSX specific metafiles as noted by kch.

Anyway, does anyone know of the solution to these problems, or is there just a plain easier way to script this?

like image 825
Dana the Sane Avatar asked May 05 '26 12:05

Dana the Sane


1 Answers

I settled on the following solution with sed.

tar cjf ~/deploy.tar.bz2 \
`git diff --name-only 0abc 1def|sed -e "s/ /\\\ /g"`
like image 109
Dana the Sane Avatar answered May 08 '26 00:05

Dana the Sane



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!