See (list) files changed between local and remote branch - git

Viewed 8542

How do I list files that are "diff"ed between my current local and the corresponding remote branch?

The situation is that I had made a push to remote earlier and since then have rebased off master + squashed some commits.

On doing a git status, I get

Your branch and 'origin/YourBranch' have diverged, and have 11 and 2 different commits each, respectively.

I do not want to do a "git diff origin/YourBranch YourBranch" because the number of changes made is large. After confirming that the files which have changed between local and remote makes sense, I shall do a force push.

1 Answers

To list just file names, use the name-only flag like this:

git diff --name-only origin/YourBranch YourBranch

name-only will (from the Git doc):

Show only names of changed files

BTW, this can also be used for other commands, such as show.

Related