Recently I tried to merge a Pull Request from CodePlex directly in Visual Studio. However, if the Pull Request comes from a forked repository, there is no way around using the command line tools to pull the remote branch into a local branch. It is actually very simple; just perform the following steps.
Pull the changes
Note: If the Pull Request’s branch is in the same repository, you can simply press on New Branch… in Visual Studio and select the appropriate branch in the drop down list. In this case you don’t need to do the next three steps.
In the Team Explorer‘s Branches view, select Actions / Open Command Prompt: This action opens a command prompt whose current directory is set to the root of your local Git repository.
In the command prompt, create a new local temporary branch and switch to it.
git checkout -b TemporaryBranch
Next, pull the remote branch from the fork into the temporary branch. The first parameter of the pull command is the remote repository URL, the second parameter is the name of the remote branch to pull into your temporary branch.
git pull https://git01.codeplex.com/forks/rsuter/visualjsoneditorimprovement master
Test the changes
After the previous steps, you should automatically see the new, unpublished branch “TemporaryBranch” in Visual Studio:
Now test the application with the changes from the Pull Request…
Push the changes
When everything is fine, you can merge the branch back into the “master” branch:
Right-click the “TemporaryBranch” branch and select Merge…
Select the “TemporaryBranch” branch on the left and the “master” branch on the right.
After pressing the “Merge” button, the changes are merged into the “master” branch and Visual Studio switches back to the “master” branch. Check if the merge worked without issues (e.g. compile and run unit tests).
Press the “Sync” button to push the “Unsynced Commits” back to the main repository server.
Now you can delete the “TemporaryBranch” branch directly in Visual Studio:
Note: Of course, this also works if you want to merge a Pull Request into a branch different then the “master” branch…
Do you have some suggestions about how to improve this workflow?
Tags: CodePlex, Git, GitHub, Pull Request, Source Control, Visual Studio, Visual Studio 2013