xcode 提交丢失的文件或目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8317408/
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-14 22:36:23  来源:igfitidea点击:

xcode commit missing file or directory

xcodegitsvnversion-control

提问by Hackmodford

I'm not sure what happen but when I try to commit my changes in Xcode I get an

我不确定会发生什么,但是当我尝试在 Xcode 中提交我的更改时,我得到一个

fatal: Could not switch to '/Users/charlesbutler/xCode/MA Mobile/MA MobileTests': No such file or directory

致命:无法切换到“/Users/charlesbutler/xCode/MA Mobile/MA MobileTests”:没有这样的文件或目录

I have a bunch of files like this.

我有一堆这样的文件。

Is there anything I can do to remove them from being committed. A lot of them were deleted (probably manually in the project folder by me)

我能做些什么来消除它们的提交。很多都被删除了(可能是我在项目文件夹中手动删除的)

回答by Joshua Goossen

This just happened to me. I had deleted a folder with contents from the project folder. Xcode didn't handle that well.

这只是发生在我身上。我从项目文件夹中删除了一个包含内容的文件夹。Xcode 处理得不好。

What worked to fix it was to recreate an empty folder with the same name. No need to recreate its contents.

修复它的方法是重新创建一个同名的空文件夹。无需重新创建其内容。

In your case I think you just need to create a new empty "MA Mobile" folder in the same location the old one was. Then commit. It worked for me.

在您的情况下,我认为您只需要在旧文件夹的同一位置创建一个新的空“MA Mobile”文件夹。然后提交。它对我有用。

After the first commit I deleted the new folder, then committed again. It seems that Xcode is missing the logic to handle the deletion of a whole folder with contents.

第一次提交后,我删除了新文件夹,然后再次提交。Xcode 似乎缺少处理删除包含内容的整个文件夹的逻辑。

回答by Jader Feijo

If you'd like to simply commit all changes you made, doing so through the Terminal should fix the problem.

如果您只想提交所做的所有更改,通过终端执行此操作应该可以解决问题。

Open the Terminal App and cd into your project directory, once there type in the following command:

打开终端应用程序并 cd 进入您的项目目录,一旦输入以下命令:

git commit -a

Enter your commit message by pressing 'i' and typing it in, then press 'Esc', then ':', and type 'wq'

通过按“i”并键入来输入您的提交消息,然后按“Esc”,然后按“:”,然后键入“wq”

All done, you're problem should be fixed.

一切都完成了,你的问题应该得到解决。

回答by Userich

Jader Feijo's answer solve my problem.

Jader Feijo 的回答解决了我的问题。

Just want to suggest an easier way to add comment, without all this additional Vi steps, by simply adding -m parameter:

只是想建议一种更简单的添加注释的方法,无需所有这些额外的 Vi 步骤,只需添加 -m 参数:

git commit -a -m "Commit Message"

回答by Till

Assuming that you are using GIT - run the following in your command line;

假设您正在使用 GIT - 在命令行中运行以下命令;

cd "/Users/charlesbutler/xCode/MA Mobile"
git rm -r "MA MobileTests"

回答by Rory O'Bryan

I had this problem after adding and then deleting sub-projects in a project that was under source control.

在受源代码控制的项目中添加然后删除子项目后,我遇到了这个问题。

I fixed it by using the GitX application, selecting the Commit View, un-staging the now non existent files from the Staged Changeslist, and then selecting Discard Changesfor the same files in the Unstaged Changeslist.

我通过使用 GitX 应用程序修复它,Commit ViewStaged Changes列表中选择、取消暂存现在不存在的文件,然后在列表中选择Discard Changes相同的文件Unstaged Changes

I then had to delete the repository from the Xcode Organiser-Repositoriesscreen and restart Xcode before things were working ok again. Xcode automatically re-adds the repository back in when the project is re-opened.

然后我不得不从 XcodeOrganiser-Repositories屏幕中删除存储库并在一切正常之前重新启动 Xcode。当项目重新打开时,Xcode 会自动重新添加存储库。

Perhaps someone with GIT expertise can provide a command line alternative that performs a "Discard all changes that are no longer present on disk" action

也许具有 GIT 专业知识的人可以提供一个命令行替代方案来执行“放弃磁盘上不再存在的所有更改”操作

回答by ben

I've had this problem because somehow a folder of the project was added to .gitignore, I removed it from there and committed the missing files. Xcode did not show me that the folder was in gitignore or that he was different from the other folders in any way.

我遇到了这个问题,因为不知何故项目的一个文件夹被添加到 .gitignore,我从那里删除了它并提交了丢失的文件。Xcode 没有告诉我该文件夹在 gitignore 中,或者他与其他文件夹有任何不同。