DEV Community

Discussion on: How do y'all patch other people's PRs in your local dev env?

Collapse
 
hoelzro profile image
Rob Hoelz

For this, I have the following refspec in my projects' .git/config under [remote "origin"]:

fetch = +refs/pull/*/head:refs/pull/*

That way, whenever I git fetch, I have all of the PR commits under refs/pull/*, so if I want to try out the code for PR 123, I just need to git checkout pull/123 and go from there. You could also do something like +refs/pull/*/merge:refs/pr-merges/* if you want to check against the commits merging into the target branch, too!

Collapse
 
nickgrim profile image
Nick Grimshaw

Is this assuming that the remote is Github?

Collapse
 
hoelzro profile image
Rob Hoelz

Yes - I should have mentioned this is specific to GitHub! I don't know if other hosting platforms implement PRs the same way (ie. refs on the main repo), but if they do (or to find out if they do), you can do git ls-remote origin to list all of the refs on the remote and see if any pattern emerges from the output.