'Git : explore folders tructure of old commit without checking it out
I want to look at the folder structure of an old commit that I cannot checkout anymore (it had some Git LFS stuff which is now broken beyond my power to repair it).
I can already diff it to its parent and learn a lot, but I also want to see the contents of other folders and files (even if they weren't modified by that commit).
Solution 1:[1]
You could combine git ls-tree
and git cat-file
to quickly show any file with part of a pattern.
In a Windows CMD:
git ls-tree --full-tree -r @ | awk '/comm/ { cmd="git cat-file blob " $3; print "\n\n"$4"\n-------"; while ((cmd^|getline result)^>0) { print result }; close(cmd) }'
In a git bash:
git ls-tree --full-tree -r @ | awk '/comm/ { cmd="git cat-file blob " $3; print "\n\n"$4"\n-------"; while ((cmd|getline result)>0) { print result }; close(cmd) }'
Replace 'comm
' with any part of the files you want to see.
Or use awk '// ...'
to list all the files and display their content.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | VonC |