Is there a quick way to “git diff” from the point or branch origin?

后端 未结 7 1197
北恋
北恋 2020-12-23 11:21

I have looked at various SO answers on using git diff and git revisions (HEAD, ORIG_HEAD, FETCH_HEAD, etc.) and I still haven\'t found an easy way to list the c

7条回答
  •  再見小時候
    2020-12-23 11:41

    You can find the branch point using git merge-base. Consider master the mainline and dev the branch whose history you are interested in. To find the point at which dev was branched from master, run:

    git merge-base --fork-point master dev
    

    We can now diff dev against this basis:

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

    If dev is the current branch this simplifies to:

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

    For more information see the git-merge-base documentation.

提交回复
热议问题