无法提交到 git repo。Pathspec 'origin' 与 git 已知的任何文件都不匹配

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21177685/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 09:35:42  来源:igfitidea点击:

Unable to commit to git repo. Pathspec 'origin' did not match any file(s) known to git

ruby-on-railsgit

提问by Sajad

I'm working off of an existing project that I have been committing and pushing to git. For a couple reasons, I had to change rails versions from 4.0 to 3.2.6 and use existing project files from a tutorial by downloading the files and replacing my local app folder with them.

我正在处理一个我一直在提交并推送到 git 的现有项目。由于一些原因,我不得不将 rails 版本从 4.0 更改为 3.2.6,并通过下载文件并用它们替换我的本地应用程序文件夹来使用教程中的现有项目文件。

Now I can't push to my existing repo on git that I have been working on.

现在我无法推送到我一直在处理的 git 上的现有存储库。

If I try to commit, I get two errors:

如果我尝试提交,我会收到两个错误:

error: pathspec 'origin' did not match any file(s) known to git. error: pathspec 'master' did not match any file(s) known to git.

错误:pathspec 'origin' 与 git 已知的任何文件都不匹配。错误:pathspec 'master' 与 git 已知的任何文件都不匹配。

I tried to delete the local app folder, clone the repo and then replace all of the files with the 3.2.6 version app that I have been working on but I still get the same commit errors.

我尝试删除本地应用程序文件夹,克隆存储库,然后用我一直在处理的 3.2.6 版本应用程序替换所有文件,但我仍然遇到相同的提交错误。

采纳答案by VonC

You can try to specify the full git push command:

你可以尝试指定完整的 git push 命令:

git pull -u origin master

If it doesn't work, check if your remote declaration were altered in any way:

如果它不起作用,请检查您的远程声明是否以任何方式更改:

git remote -v

also, as show in this article, list references and branches:

此外,如本文所示,列出引用和分支:

git branch -avvv
git show-ref

check that you are in a branch, and not in a detached HEAD.

检查您是否在分支中,而不是在分离的 HEAD 中

Make sure you don't have a branch named 'origin' (which would be confusing here)

确保您没有名为 ' origin'的分支(这会在这里造成混淆)



As mentioned in this issue(for git svn, which isn't your case, but can still give interesting idea), trying to clone again the repo could lead to a non-corrupted .gitfolder, and the ability to push again.

本期所述(对于 git svn,这不是您的情况,但仍然可以提供有趣的想法),尝试再次克隆存储库可能会导致.git文件夹未损坏,并且能够再次推送。

回答by Onur Kucukkece

Did you checked your git config file placed in

你检查你的git配置文件放在

.git/config

in your project folder? You can find the details of your repo & branches information in this file.

在您的项目文件夹中?您可以在此文件中找到您的回购和分支信息的详细信息。

Hope it helps.

希望能帮助到你。