我尝试将“git diff”的输出放入 shell 脚本中的变量中以检查文件是否已更改,但是当在脚本中运行“git diff 文件”时,我总是得到以下输出:
usage: git diff [--no-index] <path> <path>
这是我在脚本中调用的内容
#!/bin/sh
cd /path/to/repo
jsdiff=`git diff file.js`
echo "jsdiff: $jsdiff"
有任何想法吗?
#!/bin/sh
#
# this script is always executed before the commit is typed
#
#
# Before commiting minify and compress javascript if changed
cd /path/to/repo/_js
jsdiff=`git diff main.js`
echo "jsdiff: $jsdiff"
#if [ "$jsdiff" != "" ]
# then
# compile js
# ./googleClosureCompile.sh
# echo "js minified"
#fi
exit 0;