13

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

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

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)

Till
  • 27,559
  • 13
  • 88
  • 122
Hackmodford
  • 3,901
  • 4
  • 35
  • 78
  • 1
    If you can help it, don't use XCode's git "integration". It is utterly awful; prone to overwriting entire files on conflict, committing files you've ignored, refusing to push or pull when ignored files aren't committed, and so on. *Anything else* is a major imrpovement. – ssube Feb 29 '12 at 13:30

6 Answers6

23

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

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.

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.

Joshua Goossen
  • 1,714
  • 1
  • 17
  • 36
22

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:

git commit -a

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

All done, you're problem should be fixed.

Nishant
  • 12,529
  • 9
  • 59
  • 94
Jader Feijo
  • 1,209
  • 1
  • 10
  • 11
  • After "git commit -a" my text editor popped in. Just insert the commit message there, save and close the file. – Abramodj May 09 '12 at 22:54
5

Jader Feijo's answer solve my problem.

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

git commit -a -m "Commit Message"
Userich
  • 316
  • 4
  • 4
2

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

cd "/Users/charlesbutler/xCode/MA Mobile"
git rm -r "MA MobileTests"
Till
  • 27,559
  • 13
  • 88
  • 122
  • I just get an error... (I'm really new to this git stuff) fatal: Not a git repository (or any of the parent directories): .git – Hackmodford Nov 30 '11 at 13:58
  • You will need to execute that command from within your project folder (`/Users/charlesbutler/xCode/MA Mobile` I guess) – Till Nov 30 '11 at 14:15
  • Now it says "fatal: pathspec 'MA MobileTests' did not match any files" I even tried putting a fake folder with fake contents in there (actually an old copy of what was there) and it still didn't work. – Hackmodford Nov 30 '11 at 14:44
0

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 Changes list, and then selecting Discard Changes for the same files in the Unstaged Changes list.

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

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

Rory O'Bryan
  • 1,894
  • 14
  • 22
0

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.

ben
  • 900
  • 9
  • 17