Sync your GitHub fork from within Visual Studio

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.

image

image

image

Fetch changes

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.

image

image

Merge changes

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 

image

image

image

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.

9 thoughts on “Sync your GitHub fork from within Visual Studio

  1. Exactly what I was looking for. Thank You!

    One question. I assume you are using some kind of extension, right? Is this workflow possible without any extension in Visual Studio?

    Jan

  2. A little bit off topic, but related: Is there a way to upload tags from local to remote repository via VisualStudio GUI? I know the command line version, but as you said: “once you find the trick, everything seems much more comfortable”.

    Thank you for your great work here!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s