Search code examples
gitgit-diff

git diff between working copy and branch base


I can compare the tip of master and my working copy with

git diff master

I can compare the tip of the current branch with its merge base from master with

git diff master...

Is the a git diff command to compare the merge base of the current branch and the working copy?


Solution

  • Is the are git diff command to compare the merge base of the current branch and the working copy?

    If you current branch is not master, you can try in a bash shell:

    git diff $(git merge-base --fork-point master)
    

    If uses git merge-base with --fork-point:

    git merge-base --fork-point <ref> [<commit>]
    

    Find the point at which a branch (or any history that leads to <commit>) forked from another branch (or any reference) <ref>.
    This does not just look for the common ancestor of the two commits, but also takes into account the reflog of <ref> to see if the history leading to <commit> forked from an earlier incarnation of the branch <ref>.