How to fetch down updates from a Git remote repository – 122

In Tip 117 you saw how to fetch down updates from a Git remote in Visual Studio. Note: I said “fetch down” instead of “pull down” because tip 117 only fetches the data. The result is the data for the remote tracking branches is updated, but not applied to your local branch. Hence the “incoming commits” terminology in Visual Studio.

Today you’ll see how to rinse and repeat for the command line.

First, let’s verify the currently listed branches our local remote is aware of.

$ git branch -a

git branch -a showing 3 remote tracking branches

Second, let’s add a new branch to the remote on GitHub.

I-am-a-new-branch (less than a minute ago)

Third, let’s sanity check that no magic sync’ing has happened behind the scenes.

$ git branch -a

And you’ll see the same number of remote tracking branches. (yes, I took a second screenshot. I’m too lazy to think about optimization 🙂 TBH I have to verify what I’m writing here!

git branch -a still showing 3 remote tracking branches

Fourth, run the git command to fetch

$ git fetch origin

I know you can do just `git fetch` but I don’t like learning shortcuts first.

git fetch origin creates a new tracking branch

I’m not sure if the branch on the left is the remote tracking branch or if it is the one on the right. My guess is the one on the left hand side represents the branch from GitHub and the one on the right represents the remote tracking branch.

Nonetheless, you now have a new remote tracking branch as shown below.

remotes/origin/I-am-a-new-branch

Leave a comment