Error: 无法将某些引用推送到'https://github.com/'

34

这是我的仓库 https://github.com/kiotie32/artbit-text.git 当我执行

$ git push -u origin master
remote: Repository not found.
fatal: repository 'https://github.com/kiotie32/arbit-text.git/' not found

我正在使用Windows 10电脑。我已经配置了ssh密钥以便在这台笔记本电脑上使用。 我执行ls命令,可以看到

 MINGW64 ~/.ssh
$ ls
kiotie32_rsa  kiotie32_rsa.pub  known_hosts

我阅读了此帖子上给出的所有答案。 我更改了存储在Windows凭据管理器中的密码。
我检查git remote -v | head -n1 | awk '{print $2}' | sed 's/.*\///' | sed 's/\.git//' 我得到以下输出arbit-text 我更改了存储在Windows凭据管理器中的密码,可能是存储了旧密码。
我没有收到任何弹出窗口要求输入用户名和密码。(已配置ssh密钥,但不确定是否适用于我存储在git bash中的Windows 10环境。)
现在我这样做:
$ git remote add origin https://github.com/kiotie32/arbit-text.git
fatal: remote origin already exists.

那我就这么做

$ git push -u origin master
error: src refspec master does not match any
error: failed to push some refs to 'https://github.com/kotie32/arbit-text.git'

所以我不明白为什么会出现这个错误。

我尝试了这里的解决方案https://dev59.com/vm855IYBdhLWcg3wuG0M#7572252,第一个答案是执行以下命令:
git commit -m "initial master"
然后我收到以下错误:
$ git push origin master remote: Repository not found. fatal: repository 'github.com/kotie32/arbit-text.git' not found
然后我按照评论中的方式尝试了以下命令:
git add -all,然后我执行了以下命令:
$ git push origin master remote: Repository not found. fatal: repository 'https://github.com/kotie32/arbit-text.git/' not found

然后我尝试了另一个答案https://dev59.com/vm855IYBdhLWcg3wuG0M#4183856,执行以下命令:
$ git show-ref 79d1730e9aa78f68a11ec4de6a0e8d6b66f17afb refs/heads/master
然后我执行了以下命令:
$ git push origin HEAD:master remote: Repository not found. fatal: repository 'https://github.com/kotie32/arbit-text.git/' not found

我注意到上面网址中最后一个错误中的拼写“kotie32”是错误的,它应该是 kiotie32 检查了.git文件夹中的config文件 然后我看到以下内容

[core]
        repositoryformatversion = 0
        filemode = false
        bare = false
        logallrefupdates = true
        symlinks = false
        ignorecase = true
[remote "origin"]
        url = https://github.com/kiotie32/arbit-text.git
        fetch = +refs/heads/*:refs/remotes/origin/*

所以这里的URL是正确的,拼写是kiotie32,这是正确的。

好的,我现在注意到已经形成了两个目录。 项目文件夹/.git/.git<项目文件夹>/.git的配置文件有错误的URL, 而内部的那个,即<项目文件夹>/.git/.git有正确的URL。

我更改了<项目文件夹>/.git的配置文件并删除了子目录.git/.git, 新的配置文件为

[core]
        repositoryformatversion = 0
        filemode = false
        bare = false
        logallrefupdates = true
        symlinks = false
        ignorecase = true
[remote "origin"]
        url = https://github.com/kiotie32/arbit-text.git
        fetch = +refs/heads/*:refs/remotes/origin/*

{{然后我再次执行}}
$ git push -u origin master
remote: Repository not found.
fatal: repository 'https://github.com/kiotie32/arbit-text.git/' not found

然后我做了{{某些事情}}。
$ git remote set-url origin https://github.com/kiotie32/artbit-text.git

那么现在我可以推送到主分支。


https://stackoverflow.com/search?q=%5Bgit%5D+error%3A+src+refspec+master+does+not+match+any - phd
这个回答解决了你的问题吗?git错误:无法推送一些引用 - Enlico
我现在已经删除了所有内容,并从头开始重新做了一遍。我不记得在我发布问题时出现了什么错误。目前我的笔记本电脑上的事情都正常运行。 - koeradoera
也许没有 master 分支,测试 main :D - hamid Mahmoodi
显示剩余2条评论
23个回答

-1

如果什么都不起作用,

只需检查提交的状态。

> git status

如果代码没有添加到暂存区,请执行以下操作:

git add .

检查 git 状态

git status

提交代码并拍摄快照

> git commit -m "在此处输入您的消息"

强制推送代码,覆盖现有代码和不匹配的代码。

git push -f


1
这个问题已经超过2年了,已经有25个答案了。你十分确信这个回答是否引入了新东西吗?这个回答中难道没有覆盖以上所有内容的这个回答吗?请不要重复回答,并且尤其是在回答旧问题时,请确保解释你的回答与现有回答的区别,并且最好能够更好地回答问题。 - Chris

-2
请检查您当前的分支,如果不是主分支,请尝试使用以下命令:
git branch master

这将把我们当前的分支切换到主分支。最后执行

git push -u origin master

git branch master 不会 "将当前分支更改为主分支",它会尝试创建一个主分支,但您仍然在同一分支中。 - Gino Mempin

-2

在我的情况下,将主分支更改为主要分支是有效的。

git push -u origin main

这是与此其他答案相同的解决方案。回答已有答案的旧问题时,请确保提供新颖的解决方案或比现有答案更好的解释。 - Eric Aya

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接