In Git, how can I list all files that exist in branch A that do not exist in branch B
Asked Answered
M

1

13

Is there a Git command I can use that will list the names of all files that exist in one branch that do not exist in another branch?

Background: Someone deleted some history and then pushed origin/master. Some team members have been saying they are missing some files. I think I have recovered the missing files with a patch that I created from diff commands. I branched master after the point where history was deleted and applied my patch to the new branch. Now I'd like to simply see what files exist in the new branch that do not exist at the HEAD of the master branch. For now I just want the file names, regardless of content, and only for files that exist in the new branch and do not exist at the HEAD of master.

Marry answered 2/2, 2015 at 19:6 Comment(3)
try git diff-tree and then specify a --diff-filter=D, git help diff-tree for detailsProse
@AndrewC Also add a -r flag to recurse through subdirectories. git diff-tree -r --diff-filter=D branchA branchBCockerham
Yes! The following seems to do exactly what I was looking for. git diff-tree -r --diff-filter=D HEAD..master jacobhyphenated, if you submit it as an answer I'll accept the answer. Thanks so much.Marry
P
28

You can use git diff-tree to achieve what you want

use -r to recursively descend through subtree and--diff-filter to restrict output to only certain types of diffs (for instance, deletions=D)

git diff-tree -r --diff-filter=D branchA branchB

Prose answered 2/2, 2015 at 20:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.