How to view diff of a forked github project

This is an old question, but I just found a very nice method to get a patch or diff file directly from Github.

When you are on your fork, there is a "Compare" link. Using that you are getting to the compare view.

Example

https://github.com/luisgoncalves/xades4j/compare/master...beat2:master

Now you can manually add either ".diff" or ".patch" to the end of this url, and you get the file directly in your browser.

Example

https://github.com/luisgoncalves/xades4j/compare/master...beat2:master.diff

Source: https://github.com/blog/967-github-secrets


Online solution:

get /repos/{owner}/{repo}/compare/{base}...{head}

The "compare two commits" API does support multiple repositories:

Both :base and :head must be branch names in :repo.
To compare branches across other repositories in the same network as :repo, use the format <USERNAME>:branch.

Example:

https://api.github.com/repos/octocat/hello-world/compare/master...abejpn:master

Or with a GitHub URL:

https://github.com/octocat/Hello-World/compare/master...abejpn:master


Original answer 2010:

  • Add the original GitHub repo (the one you have forked) as a remote one on your local repo.
    (git remote add mainRepo github_url)
  • git fetch mainRepo to get the latest changes from that original "mainRepo".
  • git log HEAD..mainRepo/master will show you all your changes between the latest on mainRepo master branch and your current branch.
    git diff HEAD..mainRepo/master would display it in diff format.

In learn.GitHub:

git diff mainRepo/master...HEAD

would list all your changes since you have forked from mainRepo:

This will not compare the last ‘master’ branch snapshot and the last ‘dev’ snapshot - it will instead compare the common ancestor of both with ‘dev’. That will tell you what changed since the branch point.