If you work with GitHub, a pretty common task is to update your fork with changes from the original repository. The documentation on github explains how you can do it from the command line. But since this is such a common task and merging is so much nicer from within Visual Studio I wanted to document the steps you need to do in Visual Studio.
Because Visual Studio has a native git support you can perform each step either on the command line or within Visual Studio.
Add Upstream Repository
First we have to add the remote repository as the upstream repository.
$ git remote add upstream https://github.com/otheruser/repo.git
In Visual Studio Team Explorer go to Settings / Repository Settings and add the upstream repository to remotes.
Then we can fetch changes from the upstream repository:
$ git fetch upstream
In Team Explorer under Sync / Fetch you can now select Upstream as the source.
To merge changes to your branch, you find your upstream repository in Team Explorer under Branches and can initiate the merge there.
$ git merge upstream/master
The Git integration in Visual Studio is pretty mature. But a lot of features are well hidden in the depth of the menus. But once you find the trick, everything seems much more comfortable then from the command line. You don’t need any “cheat sheets” any more.