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.
How can I find out which files have been modified in a branch?
git diff --name-only master bug1
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
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)
© 2022 - 2024 — McMap. All rights reserved.