Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Understanding the diff between two branches in a pull request ?

Borat Sagdiyev October 17, 2019

Say that a pull request is created in bit bucket to merge branch-2 into branch-1. The pull request has a diff tab to show the difference between these branches. I'd like to know the order of the comparison in the diff tab. Is it like git branch-1 branch-2, OR is it git branch-2 branch-1 ? Thanks.

1 answer

1 accepted

3 votes
Answer accepted
Daniil Penkin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 17, 2019

Hello @Borat Sagdiyev,

Thanks for reaching out.

It is neither of these commands, actually. In a pull request Bitbucket shows the difference between the potential merge state and the target branch. Here's a nice blog post describing this and the reasons behind (it is almost 5 years old now but still totally valid).

So the pseudo command is rather something like this:

git diff branch-1 <merge of branch-1 and branch-2>

Does this make sense? Let me know if you have any questions.

Cheers,
Daniil 

Borat Sagdiyev October 18, 2019

Thanks @Daniil Penkin - I have a pull request in bit bucket in which all lines of many files appear as changed (in bit bucket and source tree). When I use "git diff branch-1 branch-2", I see that each line has a "^M" character at the end. Hence, it appears as if there are many changes when there is essentially no change. I want to know which branch added the "^M" character, which is why I asked this question. So, can we say that branch-2 has introduced the "^M" character ?

Daniil Penkin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 18, 2019

If the diff shows ^M in the added line (marked with a + and highlighted with green color) and not in the removed line (marked with a - and highlighted with red color), – then yes, that character was added in one of the commits on the branch-2.

You can also switch to the side-by-side diff which might surface in a cleaner way.

^M is the carriage return character from Windows end-of-line sequence. Git client can be configured to handle this on the fly.

Hope this helps.

Cheers,
Daniil

Like Borat Sagdiyev likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events