Home > Software design >  Obtaining a list of all files uniquely that are part of a commit
Obtaining a list of all files uniquely that are part of a commit

Time:10-14

I have the following command:

git archive HEAD | tar -xC GitPulls/

This gets everything from HEAD and places it in the previously empty /GitPulls/ folder. The folder now contains many different files - say 1000 files.

I want to get a flat text list of exactly these 1000 files with no repetition -- that is, I want a list of files that git archive HEAD | tar -xC GitPulls/ will place in the /GitPulls/ folder.

I tried git log --name-only. However, this provides output that repeats the same file multiple times -- presumably for each time that the file was modified and staged and committed.

How would this change if I wanted only the contents of a specific previous commit and not the HEAD? That is, how can I obtain the unique list of files that would be unzipped into the /GitPulls/ folder on running the following: git archive <SHAID> | tar -xC GitPulls/?

CodePudding user response:

This command should do:

git ls-tree -r --name-only <commit-id>
  • Related