Grumblesaurus
Grumblesaurus

Reputation: 3119

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?

Upvotes: 1

Views: 142

Answers (2)

mnestorov
mnestorov

Reputation: 4484

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

Upvotes: 1

Judy007
Judy007

Reputation: 5860

Try using a tool such as Beyond Compare. You can just copy the PR branch directory to a temp folder, checkout master, then do a diff against the two folders. This satisfies your need well

Upvotes: 0

Related Questions