Skip to content

Instantly share code, notes, and snippets.

@joncloud
Last active April 10, 2021 07:35
Show Gist options
  • Save joncloud/8b488a656aa9eecdab725f40b91faaa6 to your computer and use it in GitHub Desktop.
Save joncloud/8b488a656aa9eecdab725f40b91faaa6 to your computer and use it in GitHub Desktop.
Checkout vsts pull requests locally

Forked from piscisaureus

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

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = ssh://[email protected]:22/DefaultCollection/Project-Name/_git/Repo-Name

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

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = ssh://[email protected]:22/DefaultCollection/Project-Name/_git/Repo-Name
	fetch = +refs/pull/*/merge:refs/remotes/origin/pull/*

Now fetch all the pull requests:

$ git fetch origin
From ssh://[email protected]:22/DefaultCollection/Project-Name/_git/Repo-Name
 * [new ref]         refs/pull/1000/merge -> origin/pull/1000
 * [new ref]         refs/pull/1002/merge -> origin/pull/1002
 * [new ref]         refs/pull/1004/merge -> origin/pull/1004
 * [new ref]         refs/pull/1009/merge -> origin/pull/1009
...

To check out a particular pull request:

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