How do you recreate the GitHub pull request diff on the commandline? How do you recreate the GitHub pull request diff on the commandline? git git

How do you recreate the GitHub pull request diff on the commandline?


The closest thing is to diff with the common ancestor between your feature-branch and your base-branch.

Something like:

git diff `git merge-base feature-branch base-branch`


If you don't want to do any git fetch and update a local PR branch, you simply can use cli/cli, the command-line interface for GitHub.

The release 0.9.0 includes gh pr diff

https://user-images.githubusercontent.com/98482/82266353-13a03300-992f-11ea-8d71-2a0995707f87.png


Not sure if there is a way to get the actual diff format closer to Github style but $ git diff master...<branch_name> seems to show the set of changes that a pull request would show (assuming it's a pull request against master). The list of changed files in a pull request seems to be equivalent to $ git diff --name-status master...<branch_name>. I guess this all assumes that your local branches are up-to-date with the remote Github branches