Compare committed revision with server one for the same branch

110 views Asked by At

There is a basic question about revision compare in git. I can compare current version with original version with

git diff HEAD^ HEAD

However, I need compare current version (origin/master) with current version of same branch on git server. It was pushed after get my original version. I tried to compare via commit id (got from web gitlab interface). However, there was the following error:

$ git difftool 866f426ce3c4d7594500ce322b68fd1d96ced06b
fatal: bad object 866f426ce3c4d7594500ce322b68fd1d96ced06b

There is an advice to use

git diff masterbranch remotebranch

For my case it looks like:

git diff master origin/master

In this case the diff is a comparison current version with original version I got as start for my changes. However, this branch was changed later. I would like to compare my version with actual state of branch origin/master not original one I used.

1

There are 1 answers

2
maggick On

2 ways to do that:

  1. directly diff with the remote server (need to be connected):

    git diff masterbranch remotebranch

    for instance

    git diff master origin

  2. Grab the code and diff localy :

    • do a fetch (the syntax is the same as git pull, but it doesn't automatically merge)
    • do a diff between your dest branch and the other branch
    • then do a merge if you want