【问题标题】:Git Push Errors when pushing to Github推送到 Github 时出现 Git 推送错误
【发布时间】:2023-03-16 02:25:02
【问题描述】:

我一直在不知疲倦地尝试将文件从 Git 推送到 Github。 从不完整的加载过程到重复文件——我需要一些认真的帮助来解决这个问题。

以下是收到的错误信息:

$ git push origin master
error: src refspec master does not match any.
error: failed to push some refs to 'https://github.com/XXXX/REPOSITORYNAME.git'

还有……

If no other git process is currently running, this probably means a
git process crashed in this repository earlier. Make sure no other git
process is running and remove the file manually to continue.

最后……

$ git add .
fatal: Unable to create 'C:/Users/XXXXX/.git/index.lock': File exists.

【问题讨论】:

    标签: github git-push git-add git


    【解决方案1】:

    我假设您的仓库不是“https://github.com/xxxx/REPOSITORYNAME.git”?您的原始主机设置为此网址。切换到正确的原点

    git remote set-url origin git://new.url.here
    

    【讨论】:

      【解决方案2】:

      最终问题的解决方案可能是:

      在窗口中: 存储库目录中的命令提示符,在您的情况下为 C:/Users/username/

      cd .git
      del index.lock
      

      【讨论】:

      • 你是否设置了准确的 oring 路径。
      【解决方案3】:

      我在没有提交的情况下进行推送时收到错误error: src refspec master does not match any。所以我所要做的就是提交一些文件,然后

      git push -u origin master
      

      这只是告诉从工作树和 linux/unix/gitbash/cygwin 中的索引中删除 index.lock 文件。

      rm -f .git/index.lock
      

      如果上述方法不起作用,请尝试以下方法。

      rm .git/index.lock
      

      这样就可以了

      如果是 Windows 命令提示符,请尝试:

      del .git\index.lock
      

      如果你的 git 崩溃了,那么你必须运行一个

      git reset
      

      删除 index.lock 文件后

      【讨论】:

      • 非常感谢您的帮助,以及其他所有人。这是我遇到的另一个错误: $ rm .git/index.lock rm: cannot remove ‘.git/index.lock’: No such file or directory
      猜你喜欢
      • 2016-12-30
      • 2015-10-28
      • 2012-10-29
      • 1970-01-01
      • 2013-05-30
      • 2016-08-02
      • 2012-06-12
      • 1970-01-01
      • 2016-03-18
      相关资源
      最近更新 更多