42

I have two branches: master and bug1. I checked out bug1, did bunch of changes and multiple commits. How do I get a list of all files that were changed on the branch? I'm not interested in hashes, dates or any other commit related details. I just want to get a simple list of touched files.

zaza
  • 1,379
  • 2
  • 13
  • 21

3 Answers3

71
git diff --name-only master bug1
Cory Petosky
  • 12,458
  • 3
  • 39
  • 44
  • This works for me. This other SO link http://stackoverflow.com/questions/10641361/git-get-all-files-that-have-been-modified-in-branch was overkill for my purposes. Cory's answer here was succinct and concise, and still works in Sept of 2015! – Eric Hepperle - CodeSlayer2010 Sep 10 '15 at 20:03
  • 9
    if commits have been added to master (not related to bug1) wouldn't they show up as well? – NSjonas Apr 04 '16 at 23:25
  • Yes, if you've pulled and master has changed, you'll see those diffs as something like "reverse diffs". But ideally, if you've pulled changes from a remote and updated master, you should also rebase/ff-merge those changes into your bug1 branch as well. If you do the whole process, the diff works as expected. – Cory Petosky Apr 06 '16 at 00:42
  • NSjonas' comment is spot on. Someone just want to know what changes were made to a branch. They should not have to do a rebase to find out. Doing so can be very destructive. – some user May 31 '23 at 00:28
12

From your master:

git diff --name-status BRANCH

See the git diff man page for details.

Arthur
  • 1,441
  • 1
  • 13
  • 17
Tim Henigan
  • 60,452
  • 11
  • 85
  • 78
1

The answer given on a question that was suggested to be a duplicate of this one, is a more correct answer to this question.

If you follow any other answers currently on this page here, you will also get in your output, any changes that have happened to master during the time that the files you are actually interested in were modified on branch.

So they are only correct in the limited subset of cases where your master happens to look exactly how it did back when the branch was forked off.

The question here specifies that it wants only the files that were modified along the branch (i.e. relative to the fork point, or "merge-base" of branch and master)

Starman
  • 336
  • 2
  • 11