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

戏子无情 提交于 2020-06-24 20:28:53

问题


While working on a branch that I've opened a pull request on, I would like to see the exact same diff that GitHub displays on the commandline. What is the particular git diff command that replicates the list of changes GitHub displays for a pull request?


回答1:


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




回答2:


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`



回答3:


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




回答4:


See the Reviewing and Synchronising section in GitHub advanced training. In particular, after fetching the pull request you can view the diff prior to merging:

$ git fetch origin refs/pull/1/head
$ git show FETCH_HEAD



回答5:


git diff branchA branchB should work, no?

More info on other perhaps useful diff notations can be found here



来源:https://stackoverflow.com/questions/26079508/how-do-you-recreate-the-github-pull-request-diff-on-the-commandline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!