Git: 1.List all files in a branch, 2.compare files from different branch

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

  1. git ls-tree -r --name-only <commit> (where instead of <commit> there can be <branch>).
    You might want to use also -t option which lists subdirectories before descending into them
  2. git diff <branchA>:<fileA> <branchB>:<fileB>,
    or if you want to compare the same file git diff <branchA> <branchB> -- <file>

To list all files added in the new branch

git diff --name-only branch1 master

Tags:

Git