Github pull request(PR) != Git diff b/w topic branch & master branch

Satyaharish Appana
2 min readMay 14, 2021

Whenever, we raise a Github pull request(PR) working on a topic/feature branch basing to master branch, we implicitly assume that it’s diff b/w my feature/topic branch and master branch which is not correct.

Let me give a scenario which occurs most common on our day to day development iterations.

Scenario — which happens most usually on a day-to-day basis
Scenario — which happens most usually on a day-to-day basis

Also, please assume that dev1 and dev2 changes do not have any intersection i.e no conflicts.

Question1: On Day5 , Will there be any difference in PR2 (when compared to Day2) raised by dev2 given dev1 had merged his changes to master on Day4 ?

Answer : No

Reason : By default, pull requests on GitHub show a three-dot diff, or a comparison between the most recent version of the topic/feature branch and the commit where the topic/feature branch was last synced with the base branch (i.e master branch in this example).

Please refer to this GitHub PR documentation for complete details.

Question2: On Day5, if we do git diff between Feature branch by Dev 2 and master branch , will it show changes committed/merged by dev1 in addition to diff shown in PR2 ?

Answer : Yes

Reason : git diff (i.e compare pages) shows the diff between the tip of the head ref and the current common ancestor (that is, the merge base) of the head and base ref.

Please refer to this GitHub Compare pages documentation for complete details.

--

--

Satyaharish Appana
0 Followers

Experienced hands on software developer. Big believer of "win-win". Always curious to learn new stuff ( tech / product / best practices or any genre).