- Looking for a command like
ls -Rordir/sthat can list all files in a commit/branch. - Is there any command that can compare two files from different branches?
ls -R or dir/s that can list all files in a commit/branch. git ls-tree -r --name-only <commit> (where instead of <commit> there can be <branch>).-t option which lists subdirectories before descending into themgit diff <branchA>:<fileA> <branchB>:<fileB>,git diff <branchA> <branchB> -- <file>To compare the same file from different branches:
git diff branch_1..branch_2 file.txt
To list all files in a tree object:
git ls-tree -r branch
git ls-filesgit ls-files described in the git-scm docu:# Switch to <branch> of interest
$ git checkout <branch>
# List all files in <branch>
$ git ls-files
For further options check the documentation.
For listing, you may use git ls-files to list all files recursively in the current index/working directory. You may refer to Git-SCM Docs / git-ls-files or type man git-ls-files if you have installed Git and have man pages available.
It has nice options to show files in different ways like cached, staged, deleted, modified, ignored or others for the untracked. It also supports matching patterns. Having also a --debug arg, you can easily list creation time, modification time, inode id, owner & group id, size and flags for files.
For the diff of two branch, simply use git diff <branch> <other branch> as stated in other answers.