screenm0nkey
screenm0nkey

Reputation: 18785

Is there a way to see all changed files on a branch in Git?

I apologise if this isn't very clear, but in Git, is there a way to see all changed files on a branch, by name only?

As far as I know, I can use git log to see files that have changed in a single commit, but I want to see all files that have changed since the branch was created, over several commits.

There is git diff, but this also lists the changed files in the branch I'm comparing to which I don't want to see. I kind of want a command that says 'show me file names for all changed files in this branch'.

Upvotes: 27

Views: 21742

Answers (4)

Pawan Maheshwari
Pawan Maheshwari

Reputation: 15356

I am using this command to find out the list of N files changed between two versions. Here N is 50.

git log  --pretty=format: --name-only <SourceBranch>...<TargetBranch> | sort | uniq -c | sort -rg | head -50

Upvotes: 0

nocache
nocache

Reputation: 1805

Assuming you have checked out the branch you are working on, and you want to compare it to master:

git diff --name-only master

Upvotes: 1

antlersoft
antlersoft

Reputation: 14786

I don't know that there is something that does exactly what you want based only on your current branch, but if you know the commit id that is the parent of your branch, you can do:

git diff --name-only <commit id of branch point>..HEAD

Upvotes: 3

Mark Longair
Mark Longair

Reputation: 467023

Supposing you're on branch foo, and you're interested in which files have changed since the point when it diverged from master, you can just do:

git diff --name-only master...

(Note the three dots.) If you're not foo, you can use the full form:

git diff --name-only master...foo

I made some graphics that explain the double-dot and triple-dot notations, and their differences between their meaning in git rev-list and git log - you can find them in this answer.

Upvotes: 57

Related Questions