acejazz
acejazz

Reputation: 819

Git: How to check if new files have been added to the remote repository, but not in local

The situation is the following: I created a remote repository so I can work with it from two different places with different machines.

Every time I work from a location generally I don't modify the old files, but I just add new files to the repository (I'm studying Java, so I'm adding all the exercises that I do in that repository).

I know that with git pull I get the newer version of the remote repository, but if I use git diff it says that there are no differences, even if in the remote repository I added new files from the other location.

Before pulling I would check if new files have been pushed to the remote repository. Is there a command that shows not only the differences on existing files, but also the new files pushed to the remote repository?

Thanks in advance.

Upvotes: 2

Views: 2111

Answers (1)

jub0bs
jub0bs

Reputation: 66244

The following command lists the files that were added between <revA> and <revB>:

git diff --diff-filter=A --name-only <revA> <revB>

In your case, <revA> would be master, and <revB> would be origin/master (under the assumption that your remote is indeed called "origin").

As jthill points out in his comment, don't forget to run

git fetch

beforehand, to make sure your local repo knows all about the latest changes in the remote.

Upvotes: 2

Related Questions