2 hours ago · Tech · hide · 0 comments

To list all files in your repository as they were at a given commit, use git ls-tree with its -r and --name-only options: $ git ls-tree --name-only -r <commit> Replace <commit> with any commit reference: a SHA, a branch name, a tag like above, a relative reference like @~ (the commit before last), and so on. For example, in a repository documenting puppy breeds: $ git ls-tree --name-only -r v1.0 README.md hound/beagle.md hound/dachshund.md pastoral/corgi.md sporting/golden-retriever.md sporting/labrador.md toy/chihuahua.md toy/pomeranian.md toy/pug.md toy/yorkshire-terrier.md Option breakdown: --name-only outputs only file names. Without it, each line also includes the file mode bits, object type, and SHA hash: $ git ls-tree -r v1.0 100644 blob 96f1db7b7d90e0d1a0057af5a2ffbc99adb1a19b README.md ... -r recurses into subdirectories. Without it, git ls-tree lists only the entries at the top level, showing subdirectories as tree entries. Why not git ls-files? git ls-files also lists…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.