Git

How to Check for Changes on Remote (origin) Git Repository?

On Git, many developers work on the same development project. They clone the remote repository and make changes locally on their local system. Before making modifications, each developer needs to check for the changes made by other team members on the same project. Checking for remote changes is essential to ensure that everyone is working on the project’s latest version. Moreover, it avoids conflicts between the different versions of the same file.

This blog will explain the methods to view the changes on the remote Git repository.

How to View Changes on Remote Git Repository?

To check for changes or modifications on the remote Git repository, various commands can be used, such as:

Method 1: View Remote Changes Using the “git diff” Command

The “git diff” command compares and shows the changes in the project. To view the changes on the remote repository, utilize the “git diff origin/<branch-name>” command.

Step 1: Clone Remote Repository

First, execute the provided command along with the remote repository’s URL to clone it to the local repository:

git clone https://github.com/laibayounas/demoRepository.git

 

Step 2: Fetch Remote Origin

Then, get or download the remote changes in the local repository:

git fetch origin

 

Step 3: View Remote Changes

Now, write out the following command along with the remote branch name to view its changes:

git diff origin/master

 
The below output shows the remote repository’s file and its content:


Note: Now, make some changes in the remote repository and to view those changes by following the next provided steps.

Step 4: Fetch Remote Changes

To get the new changes of the remote repository, fetch its content:

git fetch origin

 

Step 5: View New Changes

Execute the following command with the remote branch name and view new remote changes:

git diff origin/master

 
In the below screenshot, the old and new changes of the remote repository can be seen:

Method 2: View Remote Changes Using the “git log” Command

The “git log” command shows the history/record of all the changes made to the Git project. Run the “git log origin/<branch-name>” command to view the modifications on the GitHub repository:

git log origin/master

 
The below output displays all the history of the remote repository:

Method 3: View Remote Changes Using the “git whatchanged” Command

The “git whatchanged” command is almost the same as the “git log” command. However, it shows the output in raw format by default. Run the “git whatchanged origin/<branch-name>” command to check the changes on the GitHub repository:

git whatchanged origin/master

 
The below output shows the output in raw format. The “M” status represents the modified files, and “A” shows the newly added/created files:


That was all about checking for changes on the remote Git repository.

Conclusion

Multiple Git commands are available to view remote repository changes, such as “git diff origin/<branch-name>”, “git log origin/<branch-name>” and “git whatchanged origin/<branch-name>” commands. This blog explained the methods to view the changes on the remote Git repository.

About the author

Laiba Younas

I have done bachelors in Computer Science. Being passionate about learning new technologies, I am interested in exploring different programming languages and sharing my experience with the world.