xcode commit missing file or directory

后端 未结 6 1325
日久生厌
日久生厌 2020-12-30 06:28

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\':

相关标签:
6条回答
  • 2020-12-30 06:55

    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

    0 讨论(0)
  • 2020-12-30 06:56

    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"
    
    0 讨论(0)
  • 2020-12-30 07:04

    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.

    0 讨论(0)
  • 2020-12-30 07:07

    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.

    0 讨论(0)
  • 2020-12-30 07:10

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

    cd "/Users/charlesbutler/xCode/MA Mobile"
    git rm -r "MA MobileTests"
    
    0 讨论(0)
  • 2020-12-30 07:19

    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.

    0 讨论(0)
提交回复
热议问题