如何从 git diff --no-index
中排除文件和目录?
例如,我想显示两个目录之间的差异 project1
& project2
而忽略他们的顶级.git
目录( project1/.git
和 project2/.git
)及其所有 .DS_Store
文件。
最佳答案
这不是您所要求的,但它可能会给您想要的结果:添加 project2
作为 project1
的 Remote 而只是 git diff
他们的 HEAD
s。
git remote add other ../project2/.git
git fetch other
# Perform the diff
git diff other/HEAD
如果您的 project2
还不是一个 Git 存储库,你可以暂时让它成为一个(他的 Josiah Yoder 的帽子提示 comments ):# Set up project2 repo
cd ../project2
git init
git add .
# Add as remote from project1
cd ../project1
git remote add other ../project2/.git
git fetch other
# Perform the diff
git diff other/master
# Clean up
git remote remove other
cd ../project2
rm -r .git
关于git - 如何从 git diff --no-index 中排除文件和目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49969016/