Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Obtaining a list of all files uniquely that are part of a commit

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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/?

>Solution :

This command should do:

git ls-tree -r --name-only <commit-id>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading