Reputation: 339
How can I get a list of all the files that were changed in a branch? I can't do a git-diff because the branch is already merged into master.
I would need a way to list all the commits in a branch and extract the path of the files, without duplicates.
If anybody has done a thing like this before it will be really appreciated,
a lot of thanks!
Upvotes: 8
Views: 1549
Reputation: 4821
I came across this same problem and @Michael Burtin's solution worked for the most part. However, I wanted to add this to a script that will work on any branch, so it cannot contain the branch name. This is what I came up with:
git diff --name-only $(git merge-base master HEAD)
Which finds the closet ancestor of both master and the current branch, then diffs that commit with the current branch.
Upvotes: 2
Reputation: 631
Do a git log
and figure out from which commit you want to know the differences. Let's say that you determine that the hash of the commit you want is aaaaaa
. Then run:
git diff aaaaaa --stat
Upvotes: 2
Reputation: 66
If we consider your branch as BranchA wich was branched from master, you can do:
git diff --name-status `git merge-base BranchA master`..BranchA
This will give you the list of changed files in branch prefixed with status (M for modified, A for added, D for deleted).
Upvotes: 3
Reputation: 101251
This works if the branch is pointing to the merge commit:
git diff branch_name^..master --name-only
Upvotes: 2