【问题标题】:gitolite: error: src refspec master does not match anygitolite:错误:src refspec master 不匹配任何
【发布时间】:2023-01-30 00:10:08
【问题描述】:

我使用 gitolite 创建了一个空的 git 存储库并将其克隆到我的笔记本电脑上。通常,我可以在笔记本电脑上向其中添加文件并将它们推送到存储库,但现在出现错误:

user@laptop Myproject % git clone newergit:Repo-Myrepo
Cloning into 'Repo-Myrepo'...
warning: You appear to have cloned an empty repository.
user@laptop Myproject % cd Repo-Myrepo
user@laptop Repo-Myrepo % vi test.txt
user@laptop Repo-Myrepo % git add test.txt 
user@laptop Repo-Myrepo % git commit -m "add test file to repo"
[main (root-commit) 27aa970] add test file to repo
 1 file changed, 1 insertion(+)
 create mode 100644 test.txt
user@laptop Repo-Myrepo % git push origin master
error: src refspec master does not match any
error: failed to push some refs to 'newergit:Repo-Myrepo'

这在过去曾经有效,但最近我遇到了这个错误,不知道如何继续?

【问题讨论】:

  • 运行 git statusgit branch -al 并添加它?您可能会发现默认分支现在是 main 而不是 master
  • 不幸的是, git branch -al 没有解决问题——我得到了和以前一样的错误信息。

标签: gitolite


【解决方案1】:

不幸的是,git branch -al并没有解决问题

git branch -avv 仅用于列出本地和远程分支,以便您了解创建了哪个分支(本地由您的 git commit 和远程由 Gitolite 创建)

如果你use Git 2.37+,你可以激活

git config --global push.autoSetupRemote true

从那里开始,一个简单的 git push 就足够了。它会选择正确的分支名称并通过远程跟踪将其推送到远程。

【讨论】:

    猜你喜欢
    • 2014-02-11
    • 2012-05-21
    • 2011-08-13
    • 2017-03-05
    • 2018-01-28
    • 2013-03-28
    • 2022-12-06
    • 2022-07-14
    相关资源
    最近更新 更多