the different between git diff and diff in Pull Request.

cowen January 9, 2024

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?

 

1 answer

1 vote
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 10, 2024

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 develop
git 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.

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

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events