如何获取 git 存储库中每个修订版的文件清单?
我有一个在 Microsoft Windows 上创建的 git 存储库。 Microsoft Windows 具有不区分大小写的文件系统。检查这个存储库的人并没有注意他们的文件名的大小写。这意味着同一目录或文件有时会以两个不同的名称显示。
我的意思是解决这个问题。但为了真正解决这个问题,我必须掌握它。
有没有一种快速而简单的方法来获取每个修订版的文件列表?
我需要这个来找出哪些修订版(如果有)在两个不同的名称下具有相同的文件,以便我可以决定修复此类情况的策略。这意味着我需要尽快获得大量信息,以便分析花费相当多的时间。
I have a git repository that was created on Microsoft Windows. Microsoft Windows has a case insensitive file system. The people checking into this repository have not been careful about the case of their filenames. This means that the same directory or file sometimes shows up under two different names.
I mean to fix this problem. But in order to really fix it, I have to get a handle on it.
Is there a quick and simple way to get a list of the files at each revision?
I need this in order to figure out which revisions (if any) have the same file under two different names so I can decide on a strategy for fixing such cases. This means I need to get this information en-masse as quickly as possible so the analysis consumes a resonable amount of time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实现此目的的一种方法是使用 ls-tree:(
请注意,这会查看与当前目录相对应的树部分,因此您应该从存储库的顶层运行它,或者给出
--full-tree
选项。)这本质上是瞬时的,因为 Git 所要做的就是递归地检查树;它甚至不必查看文件的内容。
我不确定您将如何使用文件名列表来检测两个不同名称下的同一文件。如果您只是想查找在不区分大小写的文件系统上相同的文件名,那么文件名列表就是您所需要的。
但是,如果您认为这些文件实际上可能具有相同的内容,则可以删除
--name-only
,这样您还可以看到所有文件的 SHA1,并可以找到相同的文件通过寻找重复的哈希值。One way to get this is with
ls-tree
:(Note that this looks at the portion of the tree corresponding to your current directory, so you should either run it from the top level of your repo, or give the
--full-tree
option.)This is essentially instantaneous, since all Git has to do is recursively examine the tree; it doesn't even have to look at the contents of files.
I'm not sure how you're going to use a list of filenames to detect the same file under two different names. If you just mean that you want to look for filenames that would be the same on a case-insensitive filesystem, then the list of filenames is all you needed.
However, if you think the files might actually have the same content, you could drop the
--name-only
, so that you'll also see the SHA1s of all the file, and can find identical files by looking for duplicate hashes.您可以运行如下命令:
此命令将显示 sha1 和每个修订版的已更改文件列表。
You could run something like this:
This command will show the the sha1 and the list of changed files for every revision.