错误:src refspec master不匹配任何。

时间:2022-09-11 16:22:38

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.

我试着按照这个帖子提出的解决方案,但它没有奏效,而且我仍然得到:src refspec master不匹配任何。

Here is what I did: Followed this solution

下面是我所做的:遵循这个解决方案。

// adding the file I created
$ git add .
$ git commit -m 'initial commit'
$ git push origin master
error: src refspec master does not match any.

When doing:

当进行:

$ git push origin HEAD:master
b40ffdf..a0d1423  HEAD -> master // looks promising

// adding a remote
$ git remote add devstage -f <another git>
$ git merge devstage/master -s recursive -X ours
$ git push -u devstage master
error: src refspec master does not match any.

More information:

更多信息:

$ git branch 
* origin

$ git show-ref
refs/heads/origin
refs/remotes/devstage/master
refs/remotes/origin/HEAD
refs/remotes/origin/devstage
refs/remotes/origin/master
refs/remotes/origin/origin

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

所以我肯定会错过裁判/主管/师傅,但不知道怎么去创造。

Thanks

谢谢

15 个解决方案

#1


14  

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

从git分支中,似乎您的本地分支名称是“origin”。

You can rename the branch with -mv flag, like this:

您可以使用-mv标记重命名分支,如下所示:

git branch -mv origin master

git分支-mv origin master。

After this git branch should show master :-)

在这之后,git分支应该显示master:-)

Just to make sure the name is indeed the only thing that went astray, you can run git log and look at the last few commits - and compare them to the last few commits on bitbucket website.

为了确保这个名称确实是唯一的错误,您可以运行git日志并查看最后几个提交——并将它们与bitbucket网站上的最后几个提交进行比较。

#2


38  

This should help you

这将帮助你

git init
git add .
git commit -m 'Initial Commit'
git push -u origin master

#3


22  

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

我有同样的问题,要解决它,遵循这些步骤。

 git init
 git add .
 git commit -m 'message'
 git push -u origin master    

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

在此之后,如果您仍然有这个错误,请再次执行以下步骤。

 git add .
 git commit -m 'message'
 git push -u origin master 

that worked for me and Hope it will help anyone

这对我很有效,希望它能帮助任何人。

#4


6  

I was having the SAME ERROR AGAIN AND AGAIN.

我一次又一次地犯同样的错误。

I added files in local repository and Trying the command

我在本地存储库中添加了文件并尝试了该命令。

"git push origin master"

“git push起源大师”

Showed Same Error

显示同样的错误

ALL I WAS MISSING I DID NOT COMMIT .

我所错过的只是我没有承诺。

" git commit -m 'message' "

“git提交-m '消息”

After Runnig this it worked

在Runnig之后,它工作了。

#5


1  

Try to do :

试着做:

git push origin HEAD:master

#6


0  

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

检查您是否从所需的目录(文件放置的地方)调用git命令。

#7


0  

It works when you do a a commit first! I had the same error...the did a commit of all my files, then tried push..it worked.

当你先做一个承诺的时候,它是有效的!我有同样的错误……我所有的文件都提交了,然后试了一下。它工作。

#8


0  

In my case the error was caused because I was typing

在我的例子中,错误是由于我输入的原因造成的。

git push origin master

git push来源主

while I was on the develop branch try:

当我在开发部门的时候:

git push origin branchname

git push branchname起源

Hope this helps somebody

希望这可以帮助别人

#9


0  

Run the command git show-ref, the result refs/heads/YOURBRANCHNAME If your branch is not there, then you need to switch the branch by

运行命令git show-ref,结果refs/head /YOURBRANCHNAME如果您的分支不在那里,那么您需要切换分支。

git checkout -b "YOURBRANCHNAME"

git show-ref, will now show your branch reference.

git show-ref,现在将显示您的分支引用。

Now you can do the operations on your branch.

现在可以在分支上执行操作了。

#10


0  

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

当您在分支名称中有一个typo时,通常会出现此错误。

For example you're on the branch adminstration and you want to invoke: git push origin administration.

例如,您在分支管理中,您想要调用:git推源管理。

Notice that you're on the branch without second i letter: admin(i)stration, that's why git prevents you from pushing to a different branch!

注意,您在分支上没有第二个i字母:admin(i)注册,这就是为什么git阻止您将其推到另一个分支!

#11


0  

Setup username and password in the git config

在git配置中设置用户名和密码。

In terminal, type

在终端,输入

vi .git/config

edit url with

编辑url与

url = https://username:password@github.com/username/repo.git

type :wq to save

类型:wq保存

#12


0  

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.

仅因为您的本地分支不计算远程存储库中的一个分支。git push origin HEAD:master使您可以忽略冲突并上传提交。

#13


0  

Solution: git push origin HEAD:master

Git gave me the below error when I tried simply git push. So clearly this is because Git matches the local and remote branch while pushing commits. This is the push.default behavior, you can find out more details here.

当我尝试简单的Git推送时,Git给了我以下错误。显然,这是因为Git在推动提交时匹配本地和远程分支。这是push.default行为,您可以在这里找到更多的细节。

fatal: The upstream branch of your current branch does not match
the name of your current branch.  To push to the upstream branch
on the remote, use

    git push origin HEAD:<Branch_Name>

To push to the branch of the same name on the remote, use

    git push origin <Branch_Name>

To choose either option permanently, see push.default in 'git help config'.

#14


-1  

For me, the fix appears to be "git ." (stages all current files). Apparently this is required after a git init? I followed it by "get reset" (unstages all files) and proceeded with the exact same commands to stage only a few files, which then pushed successfully.

对我来说,修复似乎是“git”(所有当前文件的阶段)。显然这是在git init之后需要的?我通过“get reset”(打开所有文件)来跟踪它,然后使用完全相同的命令来处理一些文件,然后成功地进行了推送。

   git . 
   git reset

#15


-1  

The error demo:

错误的演示:

007@WIN10-711082301 MINGW64 /d/1 (dev)
$ git add --all

007@WIN10-711082301 MINGW64 /d/1 (dev)
$ git status
On branch dev
Initial commit
Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

    new file:   index.html
    new file:   photo.jpg
    new file:   style.css

007@WIN10-711082301 MINGW64 /d/1 (dev)
$ git push origin dev
error: src refspec dev does not match any.
error: failed to push some refs to 'git@github.com:yourRepo.git'

You maybe not to do $ git commit -m "discription".

你可能不会做$ git commit -m“discription”。

Solution:

解决方案:

007@WIN10-711082301 MINGW64 /d/1 (dev)
$ git commit -m "discription"
[dev (root-commit) 0950617] discription
 3 files changed, 148 insertions(+)
 create mode 100644 index.html
 create mode 100644 photo.jpg
 create mode 100644 style.css

007@WIN10-711082301 MINGW64 /d/1 (dev)
$ git push origin dev
To git@github.com:Tom007Cheung/Rookie-s-Resume.git
 ! [rejected]        dev -> dev (fetch first)
error: failed to push some refs to 'git@github.com:yourRepo.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

#1


14  

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

从git分支中,似乎您的本地分支名称是“origin”。

You can rename the branch with -mv flag, like this:

您可以使用-mv标记重命名分支,如下所示:

git branch -mv origin master

git分支-mv origin master。

After this git branch should show master :-)

在这之后,git分支应该显示master:-)

Just to make sure the name is indeed the only thing that went astray, you can run git log and look at the last few commits - and compare them to the last few commits on bitbucket website.

为了确保这个名称确实是唯一的错误,您可以运行git日志并查看最后几个提交——并将它们与bitbucket网站上的最后几个提交进行比较。

#2


38  

This should help you

这将帮助你

git init
git add .
git commit -m 'Initial Commit'
git push -u origin master

#3


22  

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

我有同样的问题,要解决它,遵循这些步骤。

 git init
 git add .
 git commit -m 'message'
 git push -u origin master    

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

在此之后,如果您仍然有这个错误,请再次执行以下步骤。

 git add .
 git commit -m 'message'
 git push -u origin master 

that worked for me and Hope it will help anyone

这对我很有效,希望它能帮助任何人。

#4


6  

I was having the SAME ERROR AGAIN AND AGAIN.

我一次又一次地犯同样的错误。

I added files in local repository and Trying the command

我在本地存储库中添加了文件并尝试了该命令。

"git push origin master"

“git push起源大师”

Showed Same Error

显示同样的错误

ALL I WAS MISSING I DID NOT COMMIT .

我所错过的只是我没有承诺。

" git commit -m 'message' "

“git提交-m '消息”

After Runnig this it worked

在Runnig之后,它工作了。

#5


1  

Try to do :

试着做:

git push origin HEAD:master

#6


0  

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

检查您是否从所需的目录(文件放置的地方)调用git命令。

#7


0  

It works when you do a a commit first! I had the same error...the did a commit of all my files, then tried push..it worked.

当你先做一个承诺的时候,它是有效的!我有同样的错误……我所有的文件都提交了,然后试了一下。它工作。

#8


0  

In my case the error was caused because I was typing

在我的例子中,错误是由于我输入的原因造成的。

git push origin master

git push来源主

while I was on the develop branch try:

当我在开发部门的时候:

git push origin branchname

git push branchname起源

Hope this helps somebody

希望这可以帮助别人

#9


0  

Run the command git show-ref, the result refs/heads/YOURBRANCHNAME If your branch is not there, then you need to switch the branch by

运行命令git show-ref,结果refs/head /YOURBRANCHNAME如果您的分支不在那里,那么您需要切换分支。

git checkout -b "YOURBRANCHNAME"

git show-ref, will now show your branch reference.

git show-ref,现在将显示您的分支引用。

Now you can do the operations on your branch.

现在可以在分支上执行操作了。

#10


0  

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

当您在分支名称中有一个typo时,通常会出现此错误。

For example you're on the branch adminstration and you want to invoke: git push origin administration.

例如,您在分支管理中,您想要调用:git推源管理。

Notice that you're on the branch without second i letter: admin(i)stration, that's why git prevents you from pushing to a different branch!

注意,您在分支上没有第二个i字母:admin(i)注册,这就是为什么git阻止您将其推到另一个分支!

#11


0  

Setup username and password in the git config

在git配置中设置用户名和密码。

In terminal, type

在终端,输入

vi .git/config

edit url with

编辑url与

url = https://username:password@github.com/username/repo.git

type :wq to save

类型:wq保存

#12


0  

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.

仅因为您的本地分支不计算远程存储库中的一个分支。git push origin HEAD:master使您可以忽略冲突并上传提交。

#13


0  

Solution: git push origin HEAD:master

Git gave me the below error when I tried simply git push. So clearly this is because Git matches the local and remote branch while pushing commits. This is the push.default behavior, you can find out more details here.

当我尝试简单的Git推送时,Git给了我以下错误。显然,这是因为Git在推动提交时匹配本地和远程分支。这是push.default行为,您可以在这里找到更多的细节。

fatal: The upstream branch of your current branch does not match
the name of your current branch.  To push to the upstream branch
on the remote, use

    git push origin HEAD:<Branch_Name>

To push to the branch of the same name on the remote, use

    git push origin <Branch_Name>

To choose either option permanently, see push.default in 'git help config'.

#14


-1  

For me, the fix appears to be "git ." (stages all current files). Apparently this is required after a git init? I followed it by "get reset" (unstages all files) and proceeded with the exact same commands to stage only a few files, which then pushed successfully.

对我来说,修复似乎是“git”(所有当前文件的阶段)。显然这是在git init之后需要的?我通过“get reset”(打开所有文件)来跟踪它,然后使用完全相同的命令来处理一些文件,然后成功地进行了推送。

   git . 
   git reset

#15


-1  

The error demo:

错误的演示:

007@WIN10-711082301 MINGW64 /d/1 (dev)
$ git add --all

007@WIN10-711082301 MINGW64 /d/1 (dev)
$ git status
On branch dev
Initial commit
Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

    new file:   index.html
    new file:   photo.jpg
    new file:   style.css

007@WIN10-711082301 MINGW64 /d/1 (dev)
$ git push origin dev
error: src refspec dev does not match any.
error: failed to push some refs to 'git@github.com:yourRepo.git'

You maybe not to do $ git commit -m "discription".

你可能不会做$ git commit -m“discription”。

Solution:

解决方案:

007@WIN10-711082301 MINGW64 /d/1 (dev)
$ git commit -m "discription"
[dev (root-commit) 0950617] discription
 3 files changed, 148 insertions(+)
 create mode 100644 index.html
 create mode 100644 photo.jpg
 create mode 100644 style.css

007@WIN10-711082301 MINGW64 /d/1 (dev)
$ git push origin dev
To git@github.com:Tom007Cheung/Rookie-s-Resume.git
 ! [rejected]        dev -> dev (fetch first)
error: failed to push some refs to 'git@github.com:yourRepo.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.