简体   繁体   中英

How do I get a file manifest for each revision in a git repository?

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.

One way to get this is with ls-tree :

git ls-tree -r --name-only <commit>

(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.

You could run something like this:

git log --name-only --pretty="format:%H"

This command will show the the sha1 and the list of changed files for every revision.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM