git logo

Visual Studio Code fails when running “git pull” for a new project

This post was most recently updated on February 19th, 2022.

2 min read.

This article describes a simple fix to an issue (well… One or many possible issues), where git fails to pull anything from remote, throwing instead an error somewhat like this:

fatal: no such branch: 'master'

Bah. This stops you from pulling any new changes from remote, and likewise, it will stop you from pushing your new stuff out there.

Always something going wrong with git, right? But what is the reason this time exactly?


So there I was, just following a guide on I had just imported a repository from GitHub (this one, if you’re interested to Azure DevOps and tried to pull it locally. That didn’t work – instead, Visual Studio Code would throw an error and fail.

The error would be somewhat like this:

fatal: no such branch: 'master…master'
git pull --tags
[new branch] main -> origin/main
Your configuration specifies to merge with the ref 'refs/heads/master'
from the remote, but no such ref was fetched.

Ohhh, okay. Now I see what’s going on!


Somehow, importing a repo from GitHub to AzDO ended up with the primary branch being called differently, and that threw a wrench to git’s pulling gears big time.

Some time ago, Microsoft started provisioning main branches instead of the more traditional master – which admittedly comes with plenty of baggage nowadays – but didn’t automatically update old repositories. Not even their own ones, it seems. My new-ish AzDO repository came with the main branch, and didn’t want to have anything to do with primary branches named any other way!

If your default/primary/whatever-you-call-it branch is called main, this one won’t do. I have no idea where this project got the default branch from, but it failed.

I mean, to be fair, it’s probably just the way git maintains information about your repository not being very intuitive about odd issues like default branch names not matching. But still – an unseasoned git user will be baffled.

But… How do you work your way around the issue? 🤔


Luckily – it’s simple. Just follow the below steps!

Time needed: 5 minutes

How to fix a new project throwing “Your configuration specifies to merge with the ref ‘refs/heads/master’
from the remote, but no such ref was fetched.”?

  1. Open the folder where your solution/project lives in

    In Visual Studio Code’s Explorer, you can just hit Shift+Alt+R to open the folder where the currently active file is located in.

  2. Navigate to /.git and open a file called HEAD

  3. Fix the ref

    Chances are it’s something along the lines of:
    ref: refs/heads/master

    And if your default branch is expected to be called main, it should be:
    ref: refs/heads/main

  4. Save and retry!

    Now you should be good – just pull again and things should work like magic. 🪄

All good now, I hope!

Did it work for you? Did it fail miserably instead? Did you find a better solution? 😁 Let me know in the comments section below!

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments