有什么办法可以在Git中列出未修改的文件? [英] Is there any way to list the unmodified files in Git?

查看:49
本文介绍了有什么办法可以在Git中列出未修改的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

做了一些更改,这些更改是我从其他来源作为tarball提取的,我想知道哪些文件没有更改.目标是Git克隆,因此很容易看到新内容和更改内容.任何人都知道一种获取未更改列表的方法(未跟踪的除外)?

Got some changes I've pulled from another source as a tarball and I'd like to know which files have not changed. The destination is a Git clone, so it's easy to see what's new and what has changed. Anyone know a way to get a list of what has not changed (excluding untracked)?

换一种说法,我希望利用Git来查找新副本(压缩包)中可能缺少的文件(在Git中).

Said another way, I'm hoping to leverage Git to find what preexisting files (in Git) may be absent from the new copy (the tarball).

推荐答案

我无法找到纯git解决方案,但这对我有用:

I haven't been able to find pure git solution, but this is what worked for me:

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)

这篇关于有什么办法可以在Git中列出未修改的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆