1

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?

phd
  • 82,685
  • 13
  • 120
  • 165
Grumblesaurus
  • 3,021
  • 3
  • 31
  • 61
  • 3
    You can either `diff` the changes between branches like, `git diff develop..feature/A`. Pulling a new branch that is a proposal for a PR gives you the flexibility to really poke at it and change even more things, while if things are unstaged, then you risk not remembering what you poked at – mnestorov Jul 19 '19 at 05:22
  • 1
    When you say that using `git diff` after pulling the changes as a different branch doesn't show you what they changed what command exact parameters did you use? did you use the two dot notation like in mnestorov's comment? – ngood97 Jul 19 '19 at 05:40
  • Thanks, the tool I was missing was diff'ing two branches like that. – Grumblesaurus Jul 19 '19 at 05:45
  • Possible duplicate of [Comparing two branches in Git?](https://stackoverflow.com/questions/9834689/comparing-two-branches-in-git) – phd Jul 19 '19 at 07:12
  • https://stackoverflow.com/search?q=%5Bgit-diff%5D+branches – phd Jul 19 '19 at 07:12

2 Answers2

1

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
mnestorov
  • 4,116
  • 2
  • 14
  • 24
0

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

Judy007
  • 5,484
  • 4
  • 46
  • 68