How can I find out which files have been modified in a branch?
Asked Answered
C

3

43

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.

Caryl answered 17/11, 2009 at 14:38 Comment(0)
H
73
git diff --name-only master bug1
Harrus answered 17/11, 2009 at 14:43 Comment(4)
This works for me. This other SO link #10641861 was overkill for my purposes. Cory's answer here was succinct and concise, and still works in Sept of 2015!Niccolo
if commits have been added to master (not related to bug1) wouldn't they show up as well?Extraterritoriality
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.Harrus
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.Polygynist
T
12

From your master:

git diff --name-status BRANCH

See the git diff man page for details.

Thyroid answered 17/11, 2009 at 14:43 Comment(0)
I
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)

Ironware answered 21/2, 2023 at 21:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.