Showing commits made directly to a branch, ignoring merges in Git

前端 未结 3 1416
囚心锁ツ
囚心锁ツ 2020-12-22 21:49

When using git, is there a way to show commits made to a branch, while ignoring all commits that were brought in by merging?

I\'m trying to review the code changes

3条回答
  •  梦毁少年i
    2020-12-22 22:11

    --no-merges

    Both parents have equal weight in many contexts in git. If you've always been consistent in merging other changes in then you may find that this gives you what you want.

    git log --no-merges --first-parent
    

    Otherwise you may be able to exclude commits from other named branches.

    git log --no-merges ^other-branch-1 ^other-branch-2 ^other-branch-3
    

    If you want to review the changes that you are going to merge back into a principal branch then the easiest thing to do is to perform the merge on a local clone and then just look at the diff with the first parent before publishing the merge.

提交回复
热议问题