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

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

.




 

#To update your local.

git fetch --all
this will fetch everything from the remote, so when you check difference, it will compare the difference with the remote branch.

#to list all branches
git branch -a
the above command will display all the branches.

#to go to the branch you want to check difference
git checkout <branch_name>
#Make the changes
#to check on which branch you are in, use
git branch
    (or)
git status
Now, you can check difference as follows.

git diff origin/<branch_name> filename
git diff origin/master "src/main/java/com.abc.PhoneServiceImpl.java"
this will compare your local branch with the remote branch

 
Post a Reply
Captcha Image