Skip to content

Instantly share code, notes, and snippets.

@EricMountain-1A
Forked from hongymagic/pr.md
Last active August 29, 2015 14:24
Show Gist options
  • Save EricMountain-1A/4eebaa277a9eb66f261e to your computer and use it in GitHub Desktop.
Save EricMountain-1A/4eebaa277a9eb66f261e to your computer and use it in GitHub Desktop.

Locate the section for your stash remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@stash.internal:private/repository.git

Now add the line fetch = +refs/pull-requests/*:refs/remotes/origin/pull-requests/* to this section. Obviously, change the stash url to match your project's URL. It ends up looking like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@stash.internal:private/repository.git
	fetch = +refs/pull-requests/*:refs/remotes/origin/pull-requests/*

Now fetch all the pull requests:

$ git fetch origin
From stash.internal:private/repository
 * [new ref]         refs/pull-requests/1000/from -> origin/pull-requests/1000
 * [new ref]         refs/pull-requests/1001/from -> origin/pull-requests/1001
 * [new ref]         refs/pull-requests/1002/from -> origin/pull-requests/1002
 * [new ref]         refs/pull-requests/1003/from -> origin/pull-requests/1003
...

To check out a particular pull request:

$ git checkout pull-requests/1000/from
Branch pull-requests/1000/from set up to track remote branch pull-requests/1000/from from origin.
Switched to a new branch 'pull-requests/1000/from'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment