使用git的差异问题,从而为部署文件列表 [英] 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`
内的git diff命令生成的文件列表相对包括相对路径,当我单独运行它。
The inner git diff command produces a list of files with relative including the relative path when i run it separately.
我遇到两个问题,虽然,我需要能够输出自动逃生空间,所以焦油不抱怨包含空格的<击>文件和焦油不会获取创建时,所有文件都重复的隐藏文件$ p $由pceded'。不使用ls -al 击>显示出来。这些都是具体的OSX图元文件作为由KCH说。
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?
推荐答案
我决定与SED以下解决方案。
I settled on the following solution with sed.
tar cjf ~/deploy.tar.bz2 \
`git diff --name-only 0abc 1def|sed -e "s/ /\\\ /g"`
这篇关于使用git的差异问题,从而为部署文件列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!