Search code examples
gitremote-branch

How to compare local master with remote master in Git?


I have made few changes in my remote code on github.com. Now, I need to compare my local master branch with origin. I am using below command to get the diff, but I don't see the diff on the terminal.

git diff master origin/master

If I use the below command, I can pull the latest from origin & I can see my changes pulled in.

git pull origin master

How can I see the diff in master & origin/master without using git pull?


Solution

  • Try running the following command:

    git fetch 
    git diff remote/branch
    

    git fetch updates your tracking branches from the remote.

    git diff will compare the remote branch with your local branch.