如何排除文件和来自git diff的目录--no-index [英] How to exclude files & directories from git diff --no-index
问题描述
如何排除文件& git diff --no-index
?
How do I exclude files & directories from git diff --no-index
?
例如,我要显示两个目录之间的差异 project1
& project2
,而忽略其顶级 .git
目录( project1 / .git
和 project2 / .git
)及其所有 .DS_Store
文件。
For example, I want to show the differences between two directories project1
& project2
while ignoring their top-level .git
directories (project1/.git
& project2/.git
) and all their .DS_Store
files.
推荐答案
这并非您所要求的,但是它可能会为您提供所需的结果:添加 project2
作为 project1
的远程对象,而只是 git diff
他们的 HEAD
s。
This is not exactly what you asked for, but it might give you the results you want: Add project2
as a remote of project1
and just git diff
their HEAD
s.
git remote add other ../project2/.git
git fetch other
# Perform the diff
git diff other/HEAD
如果 project2
尚未成为Git仓库,您可以暂时将其设置为一个( Josiah Yoder 的评论):
If your project2
is not already a Git repo, you can temporarily make it one (hat tip to Josiah Yoder for his 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 diff的目录--no-index的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!