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

why when I use git ls-tree it shows the whole directory instead of the files of the commit?

I’m trying to see files which they were committed in a certain commit via git ls-tree but instead of that it shows my whole directory, I tested that in multiple commits and the result is the same.

expected result:

$ git ls-tree head
100644 blob ce4cd2cb0786a5bced850f90dfcbff89db7d04d3    lome.txt

output:

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

$ git ls-tree head
100644 blob aa491f5e3957ba167426557bc64c49bb5d585b38    a.js
040000 tree 340c695e5566ac5d2b0d52e49a88be2aa3d2de7b    hello
100644 blob ce4cd2cb0786a5bced850f90dfcbff89db7d04d3    lome.txt
100644 blob 55b22fd33cc353103412c20b6ad99fb19bed3cfb    lome11.txt
100644 blob 08da3212bb2f49a2bd6774567fd2ae483940e2bc    lome111.txt
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391    lome1111
100644 blob 178de085c0f8c798eae5dedc9e83145f852adb80    lome44.txt
100644 blob ba9d715a5b4d262a2432ec436f8f6020a29eb017    lome444.txt
100644 blob 40b3181807db07827b87a1c2086faaed15c4a953    lome5.ttx
100644 blob 461c13392c462c1d743dada3acc66a90cd9a25b7    lome5.txt
100644 blob 300220e0ceea89d36cebc852428890a28c45e701    lome7.txt
040000 tree 494990e9780f9a79526285c0321280e3f407fae5    new

>Solution :

You have not understood what a commit is (and therefore, what Git is), and thus your expectations are wrong. A commit is a snapshot of all the files in your project, regardless of whether a particular file has changed since the previous commit. Every commit contains all the files.

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