Hi Team,
I have done some test for git diff and pull requests.
I found out that the result shown by git diff is different from the result of pull request in portal.
Could you help to explain it?
Hi @cowen,
The following two commands take into account changes in both branches and will show the result of the merge commit:
git diff main developgit diff main..develop
Pull requests in Bitbucket Cloud use a three-dot diff, equivalent to
git diff main...develop
A three-dot diff shows only changes on the second branch (source branch) starting at a common ancestor of the two branches.
I am copying from the Git documentation (https://git-scm.com/docs/git-diff :
git diff [<options>] <commit> <commit>… <commit> [--] [<path>…] This form is to view the results of a merge commit. The first listed <commit> must be the merge itself; the remaining two or more commits should be its parents. Convenient ways to produce the desired set of revisions are to use the suffixes ^@ and ^!. If A is a merge commit, then git diff A A^@, git diff A^! and git show A all give the same combined diff. git diff [<options>] <commit>..<commit> [--] [<path>…] This is synonymous to the earlier form (without the ..) for viewing the changes between two arbitrary <commit>. If <commit> on one side is omitted, it will have the same effect as using HEAD instead. git diff [<options>] <commit>...<commit> [--] [<path>…] This form is to view the changes on the branch containing and up to the second <commit>, starting at a common ancestor of both <commit>. git diff A...B is equivalent to git diff $(git merge-base A B) B. You can omit any one of <commit>, which has the same effect as using HEAD instead.
git diff [<options>] <commit> <commit>… <commit> [--] [<path>…]
This form is to view the results of a merge commit. The first listed <commit> must be the merge itself; the remaining two or more commits should be its parents. Convenient ways to produce the desired set of revisions are to use the suffixes ^@ and ^!. If A is a merge commit, then git diff A A^@, git diff A^! and git show A all give the same combined diff.
^@
^!
git diff A A^@
git diff A^!
git show A
This is synonymous to the earlier form (without the ..) for viewing the changes between two arbitrary <commit>. If <commit> on one side is omitted, it will have the same effect as using HEAD instead.
..
This form is to view the changes on the branch containing and up to the second <commit>, starting at a common ancestor of both <commit>. git diff A...B is equivalent to git diff $(git merge-base A B) B. You can omit any one of <commit>, which has the same effect as using HEAD instead.
git diff A...B
git diff $(git merge-base A B) B
You can find more details about pull request diffs in the following blog post, including what you can do if you want to see changes to the destination branch in a pull request:
Please feel free to reach out if you have any questions!
Kind regards,Theodora
It looks like you're new here. Sign in or register to get started.