Error src refspec main does not match any что это

Сообщение ‘src refspec master не соответствует никому’ при нажатии на коммиты в Git

Я клонирую свой репозиторий с помощью:

Но ошибка, которую я получаю обратно:

Может быть, вам просто нужно совершить. Я столкнулся с этим, когда я сделал:

К сожалению! Никогда не совершал!

Все, что мне нужно было сделать, это:

Вы можете попробовать git push origin HEAD:master как более локально-независимое решение. Это явно говорит о том, что вы хотите передать локальный ref HEAD в удаленный ref master (см. Документацию git-push refspec ).

У меня также была похожая ошибка после удаления всех файлов на моем локальном компьютере, и я должен очистить все файлы в хранилище.

Мое сообщение об ошибке было что-то вроде этого:

И это было решено путем выполнения следующих команд:

Поэтому я попробовал решение Ви :

Это сработало для меня.

Для этого вам нужно ввести сообщение о коммите следующим образом, а затем нажать на код:

Успешно подтолкнул к мастеру.

Мне нужно было убедиться, что открытый ключ правильно настроен на сервере (добавлен в

Это сработало для меня в конце концов.

Я обнаружил, что это произошло в совершенно новом хранилище после того, как я добавил Git только каталог.

Как только я добавил файл (например, README), Git push работал отлично.

Чтобы исправить это, переинициализируйте и следуйте правильной последовательности:

Чтобы исправить это, повторно инициализируйте и следуйте правильной последовательности кода:

Сначала убедитесь, что вы добавили, а затем подтвердите / нажмите:

дополнение

Одной из основных причин этой проблемы является то, что некоторые Git-серверы, такие как BitBucket, не master инициализируют свою ветвь при клонировании свежего репозитория.

Это также происходит, когда вы находитесь в определенной ветке и пытаетесь выдвинуть другую ветку, которая еще не существует, например:

Для меня следующие работали, чтобы переместить неотслеживаемые файлы:

Далее я выполнил аналогичные шаги

Последний по порядку, но не по значимости:

Когда вы это сделаете, появится окно безопасности Windows с запросом вашего имени пользователя и пароля.

Запустите терминал, и в вашем проекте выполните следующие команды:

Просто добавьте начальный коммит. Следуй этим шагам:

git push origin master

Это сработало для меня.

Моя проблема заключалась в том, что ветка ‘master’ еще не была создана локально.

создал главную ветку, после чего быстро

перенес работу в репозиторий Git.

Вы, вероятно, забыли команду «git add». после команды «git init».

Я также следовал указаниям GitHub, как указано ниже, но я все еще сталкивался с той же ошибкой, о которой упоминал OP:

Доказательством этого является то, что когда я печатаю, я git status обычно получаю зеленые шрифты для добавленных файлов. Но все было красным. Как будто это не было добавлено вообще.

Источник

Ошибка git push: src refspec main не соответствует ни одному в Linux

2 ответа

Это ответ, состоящий из нескольких частей, потому что здесь есть две отдельные проблемы, которые сейчас переплетаются. Вот краткое изложение того, что мы рассмотрим:

Каждый из них находится в отдельном разделе.

main против master

В исходном коде и документации также есть множество других строковых литералов, читающих master ; они преобразуются для использования параметров конфигурации, но на это потребуется время.

error: src refspec main does not match any

Это сообщение об ошибке от Git довольно загадочно для новичков, но на самом деле довольно просто. Проблема в том, что он загружен жаргоном (webster; wikipedia) и сокращает» источник «до» src «.

Чтобы это сработало, имя источника должно быть именем существующей ветки в нашем собственном репозитории Git. Здесь что-то идет не так.

3 Git может использовать любое имя, а не только имя ветки. Например, имя тега работает нормально. Но этот ответ касается имен веток, потому что вопрос касается имен веток, а имена веток являются наиболее распространенными для использования здесь.

Сообщение об ошибке.

Что, если вы случайно создали обе ветки?

Если мы теперь переименуем наш master в main :

А затем попробуйте нажать:

Мы получаем другую ошибку:

Здесь у вас есть несколько вариантов:

После того, как я немного исследовал и оказался пустым, я попробовал взломать. вот.

Источник

git push error: src refspec main does not match any on linux

I tried git push origin HEAD:main but produced error:

6 Answers 6

This is a multi-part answer because there are two separate issues here that are tangling together now. Here’s a summary of what we’ll cover:

Each of these is in its own section.

main vs master

1 There are some technical flaws in this kind of claim. As we know, technically correct is the best kind of correct, so let me add a few caveats in this footnote:

There are a bunch of other string literals reading master in the source and documentation as well; they’re being converted to use the configuration settings but this will all take time.

error: src refspec main does not match any

This error message from Git is quite cryptic to newbies, but is actually pretty simple. The problems are that it’s loaded with jargon (webster; wikipedia), and abbreviates «source» to «src».

Git is all about commits. When we clone a repository, we have our Git reach out to some other Git. That other Git looks up a repository, and that other repository is full of commits. We then have our Git create a new repository locally, transfer into it all of their commits, and turn all of their branch names into remote-tracking names. Then our Git creates, in this new repository, one branch name, based on one of their branch names. At least, that’s the normal process. (And, if you know what all these terms mean, good! If not, don’t worry too much about them right now. The point to remember here is that we get all their commits and none of their branches, and then we normally have our Git create one branch to match one of theirs.)

Since Git is all about commits, this process—of copying all their commits, but only copying one of their branch names to a name spelled the same in our own repository—is all we need. The fact that our Git renames all of their branch names—so that with the one exception, we don’t have any branches at all—isn’t normally very important. Our own Git deals with this later, automatically, if and when it’s necessary.

By default and convention, the way we do this using git push is pretty simple:

for instance. The git push part is the command that means send commits and ask them to set a name. The origin part is what Git calls a remote: a short name that, mostly, holds a URL. The main part at the end, here, is our branch name. That’s the one our Git is using to find our commits. We’ll have our Git send our commits, then ask their Git to set their main too.

For this to work, the source name must be the name of an existing branch in our own Git repository. This is where things are going wrong.

3 Git can use any name, not just a branch name. For instance, a tag name works fine. But this answer is about branch names because the question is about branch names, and branch names are the most common ones to use here.

To fix this, we can either git push origin master —which sends our commits and then asks GitHub to create a new branch in the GitHub repository, with that branch name being master —or rename our master to whatever name we wanted, and then use that name:

What if you’ve accidentally made both branches?

If we now rename our master to main :

and then try to push:

we get a different error:

You have a bunch of options here:

You can obtain their initial commit and rebase your commits on those commits. This can be slightly tricky, because your first commit is a root commit. If your first commit contains README and/or LICENSE files, you’ll get an add/add conflict here. In this case it’s probably simpler to just force-push.

Источник

error: src refspec master does not match any

I have tried to follow the solutions suggested in this post but it didnt work and I am still getting: src refspec master does not match any.

Here is what I did: Followed this solution

So I am definitely missing refs/heads/master but dont know how to create it.

27 Answers 27

This should help you

From git branch it appears that somehow your local branch name is «origin».

After this git branch should show master 🙂

i have same problem, to solve it, follow these steps

after this, if you still having that error, follow these steps again

that worked for me and Hope it will help anyone

Error src refspec main does not match any что это. Смотреть фото Error src refspec main does not match any что это. Смотреть картинку Error src refspec main does not match any что это. Картинка про Error src refspec main does not match any что это. Фото Error src refspec main does not match any что это

I was having the SAME ERROR AGAIN AND AGAIN.

I added files in local repository and Trying the command

«git push origin master»

After Runnig this it worked

Error src refspec main does not match any что это. Смотреть фото Error src refspec main does not match any что это. Смотреть картинку Error src refspec main does not match any что это. Картинка про Error src refspec main does not match any что это. Фото Error src refspec main does not match any что это

Try following command:

Error src refspec main does not match any что это. Смотреть фото Error src refspec main does not match any что это. Смотреть картинку Error src refspec main does not match any что это. Картинка про Error src refspec main does not match any что это. Фото Error src refspec main does not match any что это

By just adding an empty commit will fix issue by using

// above make empty commit without edit then push

Error src refspec main does not match any что это. Смотреть фото Error src refspec main does not match any что это. Смотреть картинку Error src refspec main does not match any что это. Картинка про Error src refspec main does not match any что это. Фото Error src refspec main does not match any что это

Now you can do the operations on your branch.

In my case the error was caused because I was typing

git push origin master

while I was on the develop branch try:

git push origin branchname

Hope this helps somebody

Error src refspec main does not match any что это. Смотреть фото Error src refspec main does not match any что это. Смотреть картинку Error src refspec main does not match any что это. Картинка про Error src refspec main does not match any что это. Фото Error src refspec main does not match any что это

The error demo:

Solution:

This is happend to me once I forgot to add files. So I got the same error. All you need to do is add your files.

Error src refspec main does not match any что это. Смотреть фото Error src refspec main does not match any что это. Смотреть картинку Error src refspec main does not match any что это. Картинка про Error src refspec main does not match any что это. Фото Error src refspec main does not match any что это

Error src refspec main does not match any что это. Смотреть фото Error src refspec main does not match any что это. Смотреть картинку Error src refspec main does not match any что это. Картинка про Error src refspec main does not match any что это. Фото Error src refspec main does not match any что это

Check that you call the git commands from the desired directory (where the files are placed).

This error can typically occur when you have a typo in the branch name.

Setup username and password in the git config

Only because your local branch does not math the one in your remote repository. git push origin HEAD:master Enable you to ignore the conflict and upload your commit anyway.

Error src refspec main does not match any что это. Смотреть фото Error src refspec main does not match any что это. Смотреть картинку Error src refspec main does not match any что это. Картинка про Error src refspec main does not match any что это. Фото Error src refspec main does not match any что это

The clue is in the error

error: src refspec master does not match any.

Github’s recently changed its default branch to main. Take a look here

On your local setup you could rename your local branch as shown below

or you could push from your master to main

Ensure that if you are pushing the master branch then ensure that you’re currently in the master branch if not checkout to the master branch and now push your commits. To list all current branches in your working directory use :

Your currently working branch should have an asterisk at the beginning for instance if am working on my a devstage branch it would appears as shown below :

In this case, push the commits in the devstage branch first then perform a git pull request if you want to merge the two branches that is the master and the devstage.

For a new repository, the method works for me:

Add the git URL and try to push again
git remote add origin

Since it’s a new repository, so it doesn’t matter for me to remove the git and add it again.

Error src refspec main does not match any что это. Смотреть фото Error src refspec main does not match any что это. Смотреть картинку Error src refspec main does not match any что это. Картинка про Error src refspec main does not match any что это. Фото Error src refspec main does not match any что это

It happened to me and I discovered that github was trying to verify my account. So you need these 2 commands:

FWIW, ran into same error, but believe it came about due to the following sequence of events:

Источник

Git error: src refspec master does not match any [duplicate]

I tried this:

Cloned the gitosis-admin repository to my local machine

Added the [repo carboncake] and [group carboncake] section to the end of the file

Then copied the pub key file generated by Putty (I’m using Git basg for Windows):

$cp /some/where/mithun.pub keydir/mithun.pub

Executed the following commands:

But it doesn’t create any carboncake.git in My Server.

So I followed this:

Executed the following commands on the server:

Here’s my problem:

I tried to checkout/clone the new repository from my local machine

Which returned the error:

When I tried git push origin HEAD:master it returned the error:

When I tried git push origin master:refs/heads/master it returned the error:

git show-ref on the local machine does not display anything

Also /srv/gitosis/repositories/carboncake.git/refs/heads/ directory on the server is empty.

How can I fix this?

2 Answers 2

You’ve created a new repository and added some files to the index, but you haven’t created your first commit yet. After you’ve done:

. and those errors should go away.

The quick possible answer: When you first successfully clone an empty git repository, the origin has no master branch. So the first time you have a commit to push you must do:

Which will create this new master branch for you. Little things like this are very confusing with git.

If this didn’t fix your issue then it’s probably a gitolite-related issue:

Your conf file looks strange. There should have been an example conf file that came with your gitolite. Mine looks like this:

Please make sure you’re setting your conf file correctly.

Gitolite actually replaces the gitolite user’s account with a modified shell that doesn’t accept interactive terminal sessions. You can see if gitolite is working by trying to ssh into your box using the gitolite user account. If it knows who you are it will say something like «Hi XYZ, you have access to the following repositories: X, Y, Z» and then close the connection. If it doesn’t know you, it will just close the connection.

Lastly, after your first git push failed on your local machine you should never resort to creating the repo manually on the server. We need to know why your git push failed initially. You can cause yourself and gitolite more confusion when you don’t use gitolite exclusively once you’ve set it up.

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *