Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

git-diff

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.

like image 729
Omkar Neogi Avatar asked Sep 19 '18 13:09

Omkar Neogi


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.

like image 163
Jonathan.Brink Avatar answered Oct 20 '22 23:10

Jonathan.Brink