Дата релиза & версия:
Модель:
Совместимость:
Производитель:
Разрядность:
Размер:
Внимание! Перед установкой драйвера рекомендуется удалить его старую версию. Удаление драйвера особенно важно при замене оборудования или перед установкой новых версий драйверов видеокарты.

Я создал новый проект с одним файлом README.md.
И сделал команду

git clone https://github.com/xxxx/xxx.git
git add .
git commit -m "v.01"
git push origin master

Но получаю ошибку

error: src refspec master does not match any
error: failed to push some refs to https://github.com/xxxx/xxx.git

Я вводил
git show-ref

3deeeb53dda70bea0809cff5e4032011ba45ac7d refs/heads/main
27383695f3f76e87254687449d73250254560bbb refs/remotes/origin/HEAD
27383695f3f76e87254687449d73250254560bbb refs/remotes/origin/main
3deeeb53dda70bea0809cff5e4032011ba45ac7d refs/remotes/origin/master

И делал так

Maybe you just need to commit. I ran into this when I did:

mkdir repo && cd repo
git remote add origin /path/to/origin.git
git add .

Oops! Never committed!

git push -u origin master
error: src refspec master does not match any.

All I had to do was:

git commit -m «initial commit»
git push origin master

Success!

Я пытался еще так
git push origin HEAD:master
Но хоть загрузка и произошла но файлы не загрузились в github

Но это не помогло что мне делать как исправить


  • Вопрос задан

  • 54136 просмотров

  • Stepik

    Git (система контроля версий)

    1 неделя

    Далее

  • Академия Eduson

    Python-разработчик

    9 месяцев

    Далее

  • Учебный центр IBS

    DEV-007 Введение в систему контроля версий Git

    1 неделя

    Далее

Нет ветки master, вот и ругается. Ветка по умолчанию на GitHub теперь называется main.

Команда git branch -vv покажет какие ветки есть локально и с какими внешними ветками связаны.
* main 0e02250 [origin/main] v.01

Надо было делать git push origin main
Либо просто git push т. е. отправить текущую ветку в связанную с ней ветку на внешнем репозитории.
В нашем случае текущая ветка main (помеченная звёздочкой)
отслеживает исходную ветку main в репозитории обозначенном как origin

Что скрывается за сокращением origin покажет команда git remote -v

origin	https://github.com/xxx/xxx.git (fetch)
origin	https://github.com/xxx/xxx.git (push)

Пригласить эксперта

Ввожу git branch -vv — никакого ответа
git push -u origin main не работает хотя связь с удаленным репозиторием установлена

работает так
Для отправки в удаленный репозиторий
git push origin master:master

Войдите, чтобы написать ответ


  • Показать ещё
    Загружается…

Минуточку внимания

Created a private repository on GitHub and when tried to push the files from my server using the below commands, I get error: src refspec main does not match any.The complete command and error are as below:

# git add . 
# git commit -m "Initial Commit"
# git push origin main

I also used the token as per the latest git policy but didn’t work and got the below error message:

error: src refspec main does not match any.
error: failed to push some refs to 'https://ghp_....ROGL....RxUje@github.com/XXXX/XXX.git'

How to solve git error: src refspec main does not match any

Starting from October 1st, GitHub renamed master branch to main and all new repositories will create the default branch named main. Well, if you are curious to know why this change, then here’s an article explaining the reason.

Lets check the local reference head using the below command.

$ git show-ref 
95b095fb6dd8c8af48c35317af7da14bd9f9f622 refs/heads/master

The output of the above command says that the local is still refering to master head and not the newly renamed main.

To change the local reference to point to main branch, replace HEAD:master with HEAD:main in the below command.

# git push origin HEAD:master

to

# git push origin HEAD:main

The above command states that you want to push the local ref HEAD to the remote ref main.

That’s it!

Ramya Santhosh

is a Web Designer and content creator. A freelance writer on latest trends in technology, gadget reviews, How to’s and many more.

Skip to content



Navigation Menu

Sign in

Appearance settings

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Sign in

Sign up

Appearance settings

Vinzent03

/

obsidian-git

Public

  • Notifications
    You must be signed in to change notification settings
  • Fork
    436

  • Star
    9.7k

New issue

New issue

Closed

Closed

[Bug]: Error: Src refspec main does not match any error:failed to push some refs

#126

Description

callumgourlay

opened

on Oct 20, 2021

Describe the bug

When trying to create backup i recieve this error

Relevant errors (if available)

No response

Steps to reproduce

Attempt to push backup

Expected Behavior

No response

Addition context

No response

Operating system

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels

    No labels

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        You might be getting and error like…

        error : src refspec test does not match any.
        fatal : The remote end hung up unexpectedly
        error : failed to push some refs to ‘git@github.com: {username}/{projectname}.git’
        So, In this post we will try to fix this error, we have some solution regarding ‘error : src refspec test does not match any’. So, lets list down the solutions..

        Solution 1 :

        At first just try to commit all the files before pushing it into the github. This error will come when you haven’t committed the files and tried to push to the github.

        If this also doesn’t worked out for you, lets move to 2nd solution.

        Solution 2 :

        If you are working with branches and getting this error then might be you are not refrencing to the correct branch. Refspec are always in the form source:destination, so the error is telling you that might be something is wrong with your source part. If you are doing a spelling mistake or changing the case of the branch, you will get this error because branch names are case-sensitive.

        Solution 3 :

        If above two solution doesn’t worked for you then you can try using :

        git push origin HEAD:master
        OR
        git push origin «your_git_repo»:»your_branch_name»
        OR
        git push origin master —force

        So these three solution will surely make your «git push» work but if it doesn’t just check that you are trying to push a specific branch in local to a specific branch in remote. This error will also come when you are in a specific branch and try to push another that do not exist yet.

        Please Like and Share the Blog, if you find it interesting and helpful.

        Platform Notice: Data Center Only — This article only applies to Atlassian apps on the Data Center platform.

        Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

        *Except Fisheye and Crucible

        Problem

        When pushing a new repository to the Bitbucket Server, the following error is returned from the Git client:

        git push -u origin master

        error: src refspec master does not match any.
        error: failed to push some refs to 'http://stash.company.com/scm/PROJECT/REPO.git'

        Cause

        This is caused by the repository still being empty. There are no commits in the repository, and thus no master branch to push to the server.

        Resolution

        Create the first commit inside of the repository and then it can be pushed. For example, the following with create an initial commit and push it to the server.

        touch initial

        git add initial

        git commit -m "initial commit"

        git push -u origin master

        Please note that recent Bitbucket releases allow customizing the default branch name, as listed in Setting a system-wide default branch name, you can confirm what is the default branch name before executing the push command.

        If the resolution does not work, please get in touch with Atlassian Support.

        Updated on

        September 25, 2025

        Was this helpful?

        It wasn’t accurateIt wasn’t clearIt wasn’t relevant

        Любой драйвер для вашего ПК
        0 0 голоса
        Рейтинг статьи
        Подписаться
        Уведомить о
        guest

        0 комментариев
        Старые
        Новые Популярные
        Межтекстовые Отзывы
        Посмотреть все комментарии