git (管道) 两次提交之间是否更改了文件?
git (plumbing) has a file changed between two commits?
是否有 git(最好是管道)命令来检查文件在两次提交之间是否发生了变化?
我可以用一点 grep 检查这个,但这感觉不是最干净的解决方案:
git diff --name-only HEAD HEAD~4 -- filename | grep -q filename
编辑 :我希望 return 代码反映文件是否已更改。
Documentation 说你可以使用 --exit-code 选项
--exit-code
Make the program exit with codes similar to diff(1). That is, it exits
with 1 if there were differences and 0 means no differences.
git diff --exit-code HEAD HEAD~4 -- filename
是否有 git(最好是管道)命令来检查文件在两次提交之间是否发生了变化?
我可以用一点 grep 检查这个,但这感觉不是最干净的解决方案:
git diff --name-only HEAD HEAD~4 -- filename | grep -q filename
编辑 :我希望 return 代码反映文件是否已更改。
Documentation 说你可以使用 --exit-code 选项
--exit-code Make the program exit with codes similar to diff(1). That is, it exits with 1 if there were differences and 0 means no differences.
git diff --exit-code HEAD HEAD~4 -- filename