Index ¦ Archives ¦ Atom

Testing pull requests in Stash

I have started to use Stash and one of the things I've had trouble with is checking the changes a pull request makes before merging them into the master repository. When someone would issue a pull request, I would first get read access to their repository, set up a remote for their repository, fetch the changes, and then merge those changes onto a branch for testing. Here is an easier way to do it found at Atlassian:

FYI, here is how to test out pull requests locally pulling from Stash:

git fetch upstream refs/pull-requests/pull_request_id/from:new_branch_name

So, for example:

git fetch upstream refs/pull-requests/21/from:test-21

Then just switch over to that new branch and take a look. If you own the repository then "upstream" would be "origin" You can delete the branch when you are done:

git branch -D test-21

Stefano Tortarolo added an alias for git that makes this even easier:

prstash = "!f() { git fetch $1 refs/pull-requests/$2/from:$3; } ; f"

© Steve Spigarelli. Built using Pelican. Theme by Giulio Fidente on github.