Xcode - 错误:pathspec '...' 与 git 已知的任何文件都不匹配
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27325747/
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
Xcode - error: pathspec '...' did not match any file(s) known to git
提问by Abdalrahman Shatou
I am using a local git repo. When I try to commit changes to the core data model file (.xcdatamodel), I get this message:
我正在使用本地 git 仓库。当我尝试提交对核心数据模型文件 (.xcdatamodel) 的更改时,我收到以下消息:
error: pathspec '.../DataModel.xcdatamodeld/DataModel.xcdatamodel/contents' did not match any file(s) known to git.
How to fix this and commit the model as I do with any other file?
如何解决此问题并像处理任何其他文件一样提交模型?
回答by Stan Smulders
The chosen answer is too specific to his own question and gives zero insight on the actual cause. The problem is indeed, as mentioned before the changing of a filename's case. For me personally this is because of my Macbook/OSX. Apparently Windows has the same 'thing'.
所选答案对他自己的问题过于具体,对实际原因的了解为零。问题确实是,正如在更改文件名大小写之前提到的那样。就我个人而言,这是因为我的 Macbook/OSX。显然 Windows 具有相同的“东西”。
Cause:git isn't able to recognise a change from 'filename' to 'FileName'.
原因:git 无法识别从“文件名”到“文件名”的更改。
Here's a list of solutions for anyone stumbling upon this. All should be run at the project root:
这是针对任何遇到此问题的人的解决方案列表。所有都应该在项目根目录下运行:
The Permanent fix that will work on current and future projects
适用于当前和未来项目的永久修复
Change the git case setting. The file should be committed afterwards
更改 git case 设置。该文件应在事后提交
git config core.ignorecase false --global
The Project only fix
该项目仅修复
git config core.ignorecase false
The just give me a line of code so I can move onfix - credit to Bruce
该给我一个行的代码,所以我可以继续修复-信贷布鲁斯
git commit -a -m "pathspec did not match any file(s) known to git fix"
The I get paid by the hourfix
在我得到报酬按小时修复
Delete the file. Commit. Push. Add the file again. Commit. Push.
Based on your needs you may want to revert the settings ie do:
根据您的需要,您可能想要恢复设置,即:
git config core.ignorecase true
回答by user3757614
This probably wasn't your problem, but this page has a high Google rank for the error:
这可能不是您的问题,但此页面的错误在 Google 上排名很高:
Git doesn't like renames where the source and destination differ only by case. (Windows-specific) See How do I commit case-sensitive only filename changes in Git?for solutions.
Git 不喜欢在源和目标仅因大小写而不同的情况下重命名。(特定于 Windows)请参阅 如何在 Git 中提交仅区分大小写的文件名更改?为解决方案。
回答by tf.alves
This is not a proper way to solve the problem, but it's a workaround that may help others... Do this in your terminal:
这不是解决问题的正确方法,但它是一种可以帮助其他人的解决方法......在您的终端中执行此操作:
git commit -m "<message>" <project dir>
Replace with your message, and with the directory of your project.
替换为您的消息,以及您的项目目录。
回答by Bruce Calvert
This is similar to tf.alves answer, but normally I do a
这类似于 tf.alves 的答案,但通常我会做一个
git commit -a -m "comment"
I've found that if I forget the -a and -m parameters that I get the error: pathspec message mentioned above.
我发现如果我忘记了 -a 和 -m 参数,我会收到错误:上面提到的 pathspec 消息。
回答by Anand Yadav
I got the same error using xcode 9.1. I solved it by manual commit from the terminal. The steps are as follows
我使用 xcode 9.1 遇到了同样的错误。我通过从终端手动提交解决了它。步骤如下
- move to your project folder/directory
- $ git status - you will get to know the changes done to your project
- $ git add .
- $ git commit -m"your message"
- $ git push origin master
- 移动到您的项目文件夹/目录
- $ git status - 您将了解对项目所做的更改
- $ git 添加。
- $ git commit -m"你的消息"
- $ git push origin master
Once you manually commit all the changes successfully from the terminal, then you can use source control in xcode. ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
从终端手动提交所有更改后,您就可以在 xcode 中使用源代码管理。?????????????????????????????????????????????????????? ?????????????????????????????????????????????????????? ?????????????????????????????????????????????????????? ?????????????????????????????????????????????????????? ?????????????????????????????????????????????????????? ?????????????????????????????????????????????????????? ?????????????????????????????????????????????????????? ?????????????????????????????????????????????????????? ?????????????????????????????????????????????????????? ?????????????????????????????????????????????????????? ?????????????????????????????????????????????????????? ?????????????????????????????????????????????????????? ?????????????????????????????????????????????????????? ?????????????????????????????????????????????????????? ?????????????????????????????????????????????????????? ?????????????????????????????????????????????????????? ?????????????????????????????????????????????????????? ??????????????????????????????????????????????????????????????? ?????????????????????????????????????????????????????? ?????????????????????????????????????????????????????? ?????????????????????????????????????????????????????? ???????????????????????????????????????????????????
回答by Ahsas Sharma
I faced the same issue after renaming a storyboard file. The following steps fixed it for me -
重命名故事板文件后,我遇到了同样的问题。以下步骤为我修复了它-
- Clean (Shift + Command + K)
- Build (Command + B)
- Commit
- 清洁(Shift + Command + K)
- 构建(命令 + B)
- 犯罪
Not sure but I think it could be that git was holding reference to the old file name and cleaning the build folder and building again corrected that.
不确定,但我认为可能是 git 持有对旧文件名的引用并清理构建文件夹并再次构建更正了这一点。
Hope it helps!
希望能帮助到你!
回答by Vladimir Shutyuk
I removed .xcdatamodel file, committed, added it and committed again. Not clean, but worked.
我删除了 .xcdatamodel 文件,提交,添加并再次提交。不干净,但有效。
回答by xhinoda
I fix like this:
我是这样修复的:
- Go to your project directory with the terminal (console)
- Execute the command: git status//this show you the Untracked files
- Add all Untracked files with this command: git add -A
- You can commit with xcode source control, and then push.
- 使用终端(控制台)转到您的项目目录
- 执行命令:git status//this show you the Untracked files
- 使用以下命令添加所有未跟踪的文件:git add -A
- 您可以使用 xcode 源代码控制提交,然后推送。
回答by Skyborg
I got this error in Xcode, just restarted Xcode and then commited again.
我在 Xcode 中遇到了这个错误,只是重新启动了 Xcode,然后再次提交。
回答by Oleg991
I solved the problem simply by closing XCODE and opening it again. I know it is not a cool solution, but it worked without any changes to any files on my part.
我只是通过关闭 XCODE 并再次打开它来解决这个问题。我知道这不是一个很酷的解决方案,但它在我没有对任何文件进行任何更改的情况下工作。