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.
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.
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
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.
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
This is pure Visual Studio 2015 Update 1. Everything is inculded in the Team Explorer. You don’t need any extensions.
Great! Haven’t updated yet and wasn’t aware of this. Thanks a lot.
You’re welcome. There are so many Features coming – it’s hard to keep track of all of them.
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!
I think this is still on the backlog. You can vote it up in user voice: https://visualstudio.uservoice.com/forums/330519-team-services/suggestions/10189500-support-the-ability-to-push-git-tags-to-remote 🙂
Very helpful, thanks.
Just wanted to say thanks..! Works great.
Excellent!