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个回答

2

以下情况也可能导致此错误:

  1. 如果您更改了您的github用户名、密码或电子邮件。
  2. 如果您试图向别人的分支推送提交,而您的Windows已配置为使用您的github凭据。

我在上述情况中遇到了这个错误,以下是我解决它的方法:

  1. 删除Windows凭据管理器中存储的github凭据。

  2. 然后,我尝试再次使用以下命令推送我的提交,然后它提示我输入github凭据。(如果您要推送至别人的repo,请确保输入该github用户账户的凭据)

    git push -u (repo-url) (branch-name)


1

您看到该错误是因为您的本地 git 存储库仍为空。进行一些提交,一切都会完美运行。


1
我遇到了类似的情况,但我的情况是我有一个本地仓库,我需要将其连接到远程仓库。
这是我解决它的方法:
  • 通过Github在线创建仓库并复制其地址(使用与本地文件夹相同的名称)
  • CD到本地Git仓库并添加远程 git remote add origin [添加远程仓库地址]
  • 检查本地工作分支,很可能您正在主分支上工作
  • 提交并推送到相关分支 git push origin master

0

这个问题发生在你尝试发送到一个新的仓库时,文件夹中有另一个远程源。

以下方法对我有效:

rm -rf .git/

git init

git add -A

git push -u origin main

0

我遇到了同样的错误。 然后,我意识到原始分支不再被称为原始分支。然后,我尝试了这段代码,它起作用了:

git push origin main

只需将 master 替换为 main。


0

只是给其他人的一个提示,如果你遇到这个错误,可能是因为:

  • 你不在电脑上存储代码库的主目录中。

或者

-你还没有添加或提交你的更改。

只是一个小建议。


0

我遇到了同样的问题,我执行了以下命令

git add --all

这个命令添加了所有文件,然后提交就完成了

git commit -m [message]

最后,我通过执行以下命令成功地推送了

git push -u origin main

希望这对你也有用


0

这对我有用!

git push --set-upstream origin main

0

git add .


git commit -m "message"


git push -f


-1

尝试去做:

git pull origin repo-name 

尝试一下:

git push origin repo-name

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