我做了一些更改我已经从其他来源作为tarball撤消了,我想知道哪些文件没有更改。目的地是Git克隆,因此很容易看到新的和已发生变化的内容。任何人都知道如何获得未更改的列表(不包括未跟踪)?
编辑:换句话说,我希望利用Git找到新副本(tarball)中可能缺少的预先存在的文件(在Git中)。答案 0 :(得分:1)
我无法找到纯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)
答案 1 :(得分:0)
也许:
$ git diff --name-only > tmpfile
$ git ls-files -X tmpfile
$ rm tmpfile