我从另一个来源以 tarball 的形式获取了一些更改,我想知道哪些文件没有更改。目标是 Git 克隆,因此可以轻松查看新增内容和更改内容。有人知道如何获取未更改内容的列表(不包括未跟踪的内容)吗?
编辑:换句话说,我希望利用 Git 来查找新副本(tarball)中可能缺少哪些预先存在的文件(Git 中)。
我无法找到纯 git 解决方案,但这对我有用:
diff <(git diff --name-only) <(git ls-files -- sub/dir) | grep "^>" | cut -b3-
使用命令说明:
git diff --name-only # list modified files
git ls-files -- sub/dir # list all git--tracked files in sub/dir
grep "^>" # match lines starting with '>', i.e. diff's marker for lines present in the second set but not in the first one (i.e. unmodified files)
cut -c3- # remove diff's marker (i.e. remove first two characters)
# <( command ) gives output of the command as a file (diff command needs two files to compare them)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)