Github Comparison View for 2 branches is incorrect?

前端 未结 3 1759
[愿得一人]
[愿得一人] 2020-12-25 10:22

When I do a Github comparison view between master and another branch A, Github seems to be comparing the HEAD version of A with an old

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

    Just another thought. If you want to create a pull request from the diff between your work and the head of the master branch (as per o.p.), then what you need to do is to firstly rebase your own branch off the master branch git rebase <master> and then make the pull request.

    But you typically don't need to do this, Git is very clever with merges and will normally be able to add your work in to the master branch as you want it added, even if you don't rebase first.

    0 讨论(0)
  • 2020-12-25 10:57

    Is there a way to diff the HEAD of master against the HEAD of Branch A in Github?

    [EDIT: Nope, I was wrong. I managed had a URL which looked like it would be doing the right thing and the diff on the page looked right, but that was an accident. If you really want to know more, check the history of this answer.]

    0 讨论(0)
  • 2020-12-25 11:01

    Is there a way to diff the HEAD of master against the HEAD of Branch A in Github?

    Sept 2018: yes: GitHub now explicitly supports "Three-dot and two-dot Git diff comparisons". See an example here.
    keisuke mentions in the comments a similar initiative on Bitbucket.

    Original answer 2015:

    No: as mentioned in "GitHub compare view for current versions of branches", GitHub only supports the triple dots (...) range shortcut specification.
    That is:

    This form is to view the changes on the branch containing and up to the second , starting at a common ancestor of both.

    "git diff A...B" is equivalent to "git diff $(git-merge-base A B) B".
    You can omit any one of , which has the same effect as using HEAD instead.

    The official GitHub help mentions this feature as:

    The most common use of Compare is to compare branches, such as when you're starting a new Pull Request.

    In that scenario, the PR branch starts from master (or should be rebased on top of master anyway), which means master HEAD is the base between master and the PR branch.

    But when the two branches have forked, the comparison is no longer between HEADs, but between one common ancestor and one HEAD: git diff $(git-merge-base master B) B.

    Note: even if you were to specify two SHA1 directly, as it is clearly documented in "Comparing commits", that would still do a git diff $(git-merge-base A B) B.
    That would not do a diff directly between the two commits.

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