Reputation: 61636
Currently I use this command to get a list of changed files between the develop
and master
branches:
git diff remotes/origin/master origin/develop --name-only > diffs.txt
Is there a way to exclude files that I deleted on the develop
?
Upvotes: 3
Views: 470
Reputation: 489045
TL;DR: --diff-filter=d
.
Longer, but still not very long: See the --diff-filter
option. In particular, diff-filter=AM
, for instance, keeps only those entries whose status is either A or M. These letter codes are the same as the ones shown by git diff --name-status
(and for that matter, by git status --short
)—so to show only deleted files, you'd want --diff-filter=D
.
Uppercase letters are inclusive, so if you want everything except D, you could use --diff-filter=ABCMRTUX
, which is every possible code except D, but there's a shorter variant: lowercase means exclude, so --diff-filter=d
means everything except status code D, which is of course what you want.
Note that several codes should never occur for many cases, e.g., U (unmerged) can only occur during a conflicted merge and X (unknown) should never occur at all (it's a placeholder for Git to announce a self-detected bug). Codes B and C can only occur if you turn on the corresponding options. Code R occurs only if you turn on rename detection, but it is now on by default in Git 2.9 and later. Code T is rare: it means a regular file was replaced by a symlink, or vice versa, or that what was a submodule is now a regular file or symlink, or vice versa.
Upvotes: 8