How do I see the commit differences between branches in git?

后端 未结 10 949
太阳男子
太阳男子 2020-12-04 04:13

I\'m on branch-X and have added a couple more commits on top of it. I want to see all the differences between MASTER and the branch that I am on in terms of commits. I could

相关标签:
10条回答
  • 2020-12-04 04:54

    if you want to use gitk:

    gitk master..branch-X
    

    it has a nice old school GUi

    0 讨论(0)
  • 2020-12-04 04:56

    You can easily do that with

    git log master..branch-X
    

    That will show you commits that branch-X has but master doesn't.

    0 讨论(0)
  • 2020-12-04 04:56

    I used some of the answers and found one that fit my case ( make sure all tasks are in the release branch).

    Other methods works as well but I found that they might add lines that I do not need, like merge commits that add no value.

    git fetch
    git log origin/master..origin/release-1.1 --oneline --no-merges
    

    or you can compare your current with master

    git fetch
    git log origin/master..HEAD --oneline --no-merges
    

    git fetch is there to make sure you are using updated info.

    In this way each commit will be on a line and you can copy/paste that into an text editor and start comparing the tasks with the commits that will be merged.

    0 讨论(0)
  • 2020-12-04 04:57

    If you want to compare based on the commit messages, you can do the following:

    git fetch
    git log --oneline origin/master | cut -d' ' -f2- > master_log
    git log --oneline origin/branch-X | cut -d' ' -f2- > branchx_log
    diff <(sort master_log) <(sort branchx_log)
    
    0 讨论(0)
  • 2020-12-04 04:58

    I'd suggest the following to see the difference "in commits". For symmetric difference, repeat the command with inverted args:

    git cherry -v master [your branch, or HEAD as default]
    
    0 讨论(0)
  • 2020-12-04 04:58

    Not the perfect answer but works better for people using Github:

    Go to your repo: Insights -> Network

    0 讨论(0)
提交回复
热议问题