How to compare a local git branch with its remote branch?

936    Asked by alexDuncan in Python , Asked on Jul 19, 2021

How can I see the diff between a local branch and a remote branch?

Answered by Carolyn Buckland

To compare the remote branch you just need to update the remote branch using

    git fetch

Then you can use the code for git diff between local and remote

    git diff  

You can use git branch -a to list all branches then choose the branch name from the list from the remote branch name.

Example:

git diff master origin/master (where "master" is a local master branch and "origin/master" is a remote namely origin and master branch.)



Your Answer

Interviews

Parent Categories