How to Fix Git Error "Unable to Resolve Reference refs/remotes/origin/master Reference Broken"

The Git error message “Unable to resolve reference refs/remotes/origin/master reference broken” often occur when running a git pull command.

This error indicates that Git is unable to lock the reference for the master branch in the remote repository.

unable to resolve

It’s a frustrating issue, but fear not; we’ll guide you through the steps to resolve it.

Reasons Why this Error Occur?

Before we look into the solution, let’s understand why this error occurs.

Here are a few possible reasons:

  1. The remote repository may be temporarily unavailable, which prevents Git from establishing a connection.
  2. It’s possible that the master branch has been deleted from the remote repository, leaving Git unable to find the reference.
  3. Your local repository may be out of sync with the remote repository due to various reasons, like changing some texts or file from GitHub remote repository directly.

Now, let’s proceed to fix this error.


If you know your remote repository is changed and is not in sync, then just make use of step 3 or step 4 discussed below.

Steps to Resolve the Error

1. Check if the remote repository is available.

You can do this by running the following command:

git remote -v

The git remote -v command lists all of the remote repositories that are configured for the current working directory.

The output of the command will show the name of the remote repository, the URL of the repository, and the fetch and push URLs.

list of remote repo github

So if the remote repository is not listed, then it is unavailable which mean you need to check your GitHub account to fix the issue.

2. Verify the Existence of the Master Branch

To determine if the master branch exists in the remote repository, use the following command:

git ls-remote origin master

existence of remote master branch

If the master branch doesn’t exist in the remote repository, you’ll need to address this issue separately.

You can try to recreate the branch in the remote repository or adjust your configuration accordingly.

3. Sync Your Local Repository

To sync your local repository with the remote one, run:

git fetch origin

This command fetches the latest changes from the remote repository and updates your local copy. It’s a crucial step in resolving the error.

4. Delete and Fetch the Master Branch

If the error persists after following the above steps, consider deleting the local reference for the master branch and then fetching it again.

Execute the following commands:

rm .git/refs/remotes/origin/master
git fetch

These commands will remove the local reference for the master branch and then fetch it again from the remote repository.

github repo remove and fetch

After running these commands, you should no longer encounter the error. To confirm that everything is working as expected, run:

git pull

If the issue is resolved, you should see the message “Already up to date,” indicating that your local and remote repositories are in sync.

git pull up to date

More Notes 💡

If you encounter this error for a branch other than “master,” simply replace “master” with the appropriate branch name in the commands mentioned above.

For example, if the branch name is “main” then use:

rm .git/refs/remotes/origin/main
git fetch

Hope this helps.


  1. What should I do if the remote repository is unavailable? If the remote repository is temporarily unavailable, you can’t do much except wait for it to come back online or investigate any network issues on your end.
  2. What if the master branch has been deleted from the remote repository? If the master branch has been deleted, you’ll need to recreate it in the remote repository or adjust your configuration to match the existing branches.
  3. Why is syncing the local repository important? Syncing your local repository ensures that your copy of the project is up to date with the latest changes from the remote repository, helping to prevent conflicts and errors.
  4. Can I use these steps for branches other than “master”? Yes, you can adapt these steps for other branches by replacing “master” with the name of the branch giving you the error.
  5. What if the issue still persists after following all the steps? If the problem continues, consider seeking assistance from your team or Git community forums for more specific troubleshooting tailored to your situation.