Search code examples
gitgithubgit-diff

Github - Fetch a Pull Request as unstaged changes


I'd like to fetch the proposed changes of a pull request and put them against my current master branch as unstaged changes, so I can do things like call git diff and see exactly what they are proposing, poke at it, and then decide whether I'd like to accept the pull request.

I've seen answers here which talk about pulling the changes as a different branch, but then git diff doesn't show me what they changed.

What is the best way to accomplish what I'm trying to do?


Solution

  • Having unstaged changes and then comparing them to a branch is inconvenient. You also run the risk of loosing these changes, since these changes are unstanged. You might even mess up the git tree if you poke the PR and then try to save these new changes. All in all, you are limited to the things you can do when working with unstaged data.

    An approach you can take is to pull the branch that implements the target PR, and then diff the tips of the branches like so

    git diff branchA..branchB
    

    In this case you can even diff the common ancestor of the branches for an even better understanding of where the PR is coming from

    git diff branchA...branchB