be-codified
be-codified

Reputation: 6124

Github pull request shows wrong diff

I am having two branches: - master and - develop.

I am trying to merge branch develop into master branch.

I have checked with Tower and Araxis merge, those two branches are identical. But when I do a pull request on Github, I am seeing that there are 381 files changed, like files are not on master at all.

Any ideas why this behavior?

Update: I am attaching screenshot of pull request.

enter image description here

Upvotes: 50

Views: 28245

Answers (4)

Catskul
Catskul

Reputation: 19230

Despite the misleading/broken github interface there's actually a way to get what you want. You need to drop one .

Instead of:

  • https://github.com/account/repo/compare/branchA...branchB

do

This compares branch heads instead of simply using the base branch to find the merge base.

github's reponse is what clued me in from @edwin-evans' response:

This is a result of the type of diff we use on GitHub. We use git’s three dot diff, which is the difference between the latest commit on the HEAD branch and the last common ancestor commit with the base branch.

Upvotes: 43

Peter P.
Peter P.

Reputation: 3507

I asked this of Github Support and here is their official answer:

We show what's called a "three-dot diff" which is the difference between the latest commit on the HEAD branch and the last common ancestor commit with the base branch. So if you forked off of a repo a while ago and things have changed in the parent repo since then, or if you opened a PR from the master branch and then the master branch has changed in the meantime, the diff wouldn't show that.

It sounds like you'd rather see a "two-dot diff", which would show the changes between the two most recent commits on each branch. In future you can merge the base branch back into the head branch. That updates the last common ancestor and would be more likely to show you what you're expecting to see there.

So, there you have it. Merge the target branch into your PR branch and push, and this is the simplest and (imo) most proper way to solve this. I can confirm (12/20/22) that this works as I just tried it.

Upvotes: 16

gizmo71
gizmo71

Reputation: 111

Stumbled onto this problem myself and found a solution I haven't seen here or in the referenced topic on the GitHub forum. My specific situation arose because I pushed what I thought was a single commit from which I made a new PR, and then realised I hadn't pushed the commit on the top of master it was based on (i.e. when I made the PR, GitHub's view of master was one commit behind where my local one was).

I found I could reset what GitHub sees as the starting point for the PR's branch by editing the PR to change the "merge into" target from master to something else and back again. After that it showed the diffs from actual master (as it was for me locally when I made that one commit I wanted in the PR) instead of from one commit earlier.

Upvotes: 8

Romain Valeri
Romain Valeri

Reputation: 21908

There's no reason for which the branch comparison would be different between GitHub and your local.

If you made your branch comparison on your local repo and they were identical, a diff in the pull request must mean that either branch (maybe both?) is not up-to-date with its remote counterpart.

First do a git fetch to update your remote-tracking branches, then checkout each branch and make sure both are up-to-date, either by pushing or pulling, depending on your workflow.


Edit (Summary version of comments below)

When you'll have checked with

git branch -a -vv

and

git log --all --decorate --simplify-by-decoration --oneline

the relative situation of all your branches, you should have different commits for origin/master and origin/develop, since GitHub shows that your master is behind 208 commits.

...which showed the following results :

develop and origin/develop are at commit 5db9361.
master and origin/master are at commit d5cc1b1.

Could the GitHub pull request preview be failing? (edit : it's not)

Upvotes: 2

Related Questions