#SharePointProblems | Koskila.net

Solutions are worthless unless shared! Antti K. Koskela's Personal Professional Blog

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

koskila
Reading Time 3 min
Word Count 491 words
Comments 0 comments
Rating n/a (0 votes)
View

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?

Problem

So there I was, just following a guide on docs.microsoft.com. I had just imported a repository from GitHub (this one, if you're interested https://github.com/staticwebdev/vanilla-api.git) 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
From https://dev.azure.com/Organization/Project/_git/Repository
[new branch] main -> origin/mainYour 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!

Reason

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? 🤔

Solution

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.

    This image has an empty alt attribute; its file name is image-1.png

  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!

Comments

Interactive comments not implemented yet. Showing legacy comments migrated from WordPress.
Whitewater Magpie Ltd.
© 2025
Static Site Generation timestamp: 2025-08-12T07:18:33Z