Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

  1. Looking for a command like ls -R or dir/s that can list all files in a commit/branch.
  2. Is there any command that can compare two files from different branches?
like image 580
Scud Avatar asked Dec 15 '09 22:12

Scud


People also ask

How can you find out the differences between the files in two different branches?

In order to see the commit differences between two branches, use the “git log” command and specify the branches that you want to compare. Note that this command won't show you the actual file differences between the two branches but only the commits.

How do I list all files in a branch?

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.


1 Answers

  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>
like image 106
Jakub Narębski Avatar answered Sep 20 '22 11:09

Jakub Narębski