How to download changes from a remote branch (e.g. GitHub) into your local branch in Visual Studio – 117

In yesterday’s example, you saw how to create a local branch from a remote tracking branch. In today’s tip, you’ll download new changes from the server into your local branch.

Suppose you know there are changes on a GitHub repo (in today’s example) you want to download to your computer.

First, switch to the branch you want to pull down, e.g. `for-review` is the branch with the changes I want. You can go to Team Explorer – Sync pane and click Fetch under Incoming Commits (or at the top of the pane).

Fetch incoming commits from branch for-review

After fetching, the window will show the new commits that have been downloaded but not applied to my local branch. That’s why this says “Incoming Commits”. The remote tracking branch remotes/for-review has these two commits (downloaded somewhere – not sure exactly where) but they have not been merged into your local branch (because we only “Fetched” the incoming commits, but haven’t done anything with them yet.)

downloaded commits

Now suppose you are ready to do something with these “incoming commits”, i.e. get the into your local branch `for-review`. Remember, your local branch is a just branch of the remote tracking branch, so you need to merge these 2 commits from the remote tracking branch into your local branch.

merge from origin/for-review into for-review branch 

The only thing that should look differently is the from branch name “origin/for-review”.

Click Merge to merge in the two incoming commits from the remote branch.

Go to View history to see the resulting timeline.

for-review history shows the 2 incoming commits

Sync will show 0 incoming commits now that they have been merged.

Yep, I already know what you’re thinking. I’m breaking down the steps manually and there’s this thing call Pull. Stay tuned to tomorrow’s tip 🙂

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s