Git diff between current branch and master but not including unmerged master commits

前端 未结 4 1888
长情又很酷
长情又很酷 2021-01-29 20:17

I want a diff of all changes in a branch that is not merged to master yet.

I tried:

git diff master
git diff branch..master
git diff branch...master
         


        
4条回答
  •  無奈伤痛
    2021-01-29 21:12

    According to Documentation

    git diff Shows changes between the working tree and the index or a tree, changes between the index and a tree, changes between two trees, changes resulting from a merge, changes between two blob objects, or changes between two files on disk.

    In git diff - There's a significant difference between two dots .. and 3 dots ... in the way we compare branches or pull requests in our repository. I'll give you an easy example which demonstrates it easily.

    Example: Let's assume we're checking out new branch from master and pushing some code in.

      G---H---I feature (Branch)
     /
    A---B---C---D master (Branch)
    
    • Two dots - If we want to show the diffs between all changes happened in the current time on both sides, We would use the git diff origin/master..feature or just git diff origin/master
      ,output: ( H, I against A, B, C, D )

    • Three dots - If we want to show the diffs between the last common ancestor (A), aka the check point we started our new branch ,we use git diff origin/master...feature,output: (H, I against A ).

    • I'd rather use the 3 dots in most circumstances.

提交回复
热议问题