xcode commit missing file or directory - xcode

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)

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.

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.

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"

Assuming that you are using GIT - run the following in your command line;
cd "/Users/charlesbutler/xCode/MA Mobile"
git rm -r "MA MobileTests"

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

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.

Related

Xcode merging issue

I am attempting to merge two branches, but I have four files with a "C" icon at the side of the file name, like the following:
No matter how I click the file, I cannot open it.
Meanwhile, the bottom right "Merge" button is inactive, and I am guessing that the cause for unable to select "Merge" is the icon beside the file name. Can anyone tell me what does that sign mean? And If resolving the problem with the "C" icon is enough to make the "Merge" button active so that I can merge two branches successfully?
After I click on the "C" file, and then click on some other files with A, there is a message says:
The source control operation failed because the file “XXX” could not be found. Make sure a valid file exists in the repository and try again.
I understand that I added some new files that the other branch does not have, so I guess this is the other cause for me not able to merge the two branches? However, I am confused that, if I were to fix the alert and the new file exists in the repository, doesn't it mean that I actually successfully "merge" the two branches, sine the old branch would then contain the new file? Could anyone provide any insight in this?
https://stackoverflow.com/a/20033446 helped me solve this. There was an untracked file causing the issue. The file was there on both tracks but somehow it wouldn't work.
What I did was the following:
Add the problematic file name to the .gitignore in both repos
Close Xcode
cd into main branch
git rm -r --cached .
open the project, change a file and commit.
Exit Xcode to do git add .
Open Xcode and commit again, push
cd into the problematic branch
git rm -r --cached .
open the project, change a file and commit.
Exit Xcode to do git add .
Open Xcode and commit again, now pull
Do a change, commit and push.
Now in your main, pull once again.
Both dirs are now on the same state. Edit your .gitignore file to add the problematic file back in, push from this dir and pull from the other dir.
Now both have the same clean state with the problem file included.

Error dialog "The file 'exclude' doesn't exist" when creating a new git-backed XCode project [duplicate]

When I create a new project in XCode 6.0.1, I got this error message: The file "exclude" doesn't exist
It seems to only impact the versioning of the files i.e. the generated stub files are not committed into github after the project is created.
What can cause this problem?
For me the issue was caused because I had previously created a project with the same name, and Xcode still had record of that.
To clear it out,
go to Window -> Organizer in the menu bar
Remove all of the repositories highlighted in red
To add your repository (if it's not being tracked for some reason),
Click the + (still in Window -> Organizer from the steps above)
Enter the path of your file
Make sure to change to Git from Subversion (if Xcode has Subversion set as default - it did for me.
I usually get this error if I initialize an Xcode project with a git repository, delete it and try to recreate it with the same name (casing doens't appear to make it sufficiently 'different'). Turns out, "Well I'll just start over" can leave some issues as well.
Hope this helps.
I had this issue as well, and I tracked it down to the .git-template folder included with Thoughtbot's dotfiles. Basically, Xcode expects its template folder to have info/exclude, and Thoughtbot's dotfiles don't. Creating that directory and file fixed the problem, as so (in the Terminal):
cd ~/.git_template
mkdir info
cd info
touch exclude
If you're getting this issue without Thoughtbot's dotfiles, you could probably look at ~/.gitconfig and use whatever templatedir is getting set as instead of ~/.git_template in the first command.

Remove a file form SVN repository in XCode

I have erroneously added a file to a project in Xcode and I have pushed it to the server.
Now I want to remove it.
Does removing the file from the local project will results in removing it from the remote repository too at the first commit?
Removing the file from the Xcode project isn't going to remove the file from the repository. You have to use the Organizer if you want to remove the file from the repository in Xcode.
Open the Organizer and click the Repositories button at the top of the Organizer. Select the repository's Trunk folder from the repository list on the left side of the Organizer. Select the file you want to delete. Click the Delete button at the bottom of the Organizer to remove the file from the repository.
Subversion is like one of those Roach Motels: Files check in, but they never check out.
Once you add a file to Subversion, it's there forever. You can remove it from the current revision of the repository (via the svn rm command), but you can never remove it completely. Someone will always be able to see it in a log, and someone can access it by checking out the revision of that directory right before you removed the file.
There has been a lot of debate about this feature. Most version control systems have an obliterate command of some sort that allows you to remove a version of a file or completely remove the file from the repository. The problem is that Subversion doesn't revision files -- it revisions the entire repository.
I don't know Xcode, so I can't help you with the exact steps. However, there must be a Repository view in Xcode like there is in Eclipse or a series of subcommands that deal with the repository (much like Eclipse's Team commands). You should be able to delete the file from there, then commit your change.
That will remove the file from the latest version of the code (and future versions). However, it will still be there in the repository, so someone can find it via the history log, and then checkout the version of the repository right before you deleted the file. If this file contains your Swiss bank account number, you're in trouble.
NOTE: There is a way to remove a file completely from Subversion, but you have to shutdown the repository, dump it out, filter out the file, then load the repository dump into a new repository. It is usually not worth the effort.
You can do it from command line using svn rm filename
http://svnbook.red-bean.com/en/1.6/svn.ref.svn.c.delete.html
Deleting a file from Xcode WILL delete it from your remote repo when you commit (tested with svn).
Using Xcode 4.6.3 I deleted a file from my project. Committed, and it was in turn deleted from my remote repository. When you delete from Xcode, you must select "move to trash" when prompted what to do. If you select "delete reference" then that file will remain in your remote repository, just as it remains part of your projects files but just not referenced in the actual Xcode project.
When you commit your files, count the files that have checkmarks on them, and look at the count that Xcode reports in the bottom right corner, Xcode reports one extra file! Thats the deleted file, which means its committing that change.
Once again, before committing, go to terminal and 'cd' to the directory where you had the file that you deleted. Enter this:
svn info ./yourFilesName.txt
You will see a result that says:
Schedule: delete
which means that when you do a commit, the file will be deleted from your remote repo.
When you delete from Xcode, you must select "move to trash",and then commit the ".xcodeproj" file

How to undo "add to Git repository" after creating an Xcode project?

I created a simple Xcode project to try something out and accidentally forgot to disable the Git repository option.
Now Xcode is cluttered with source control things. How can I get rid of this afterwards other than copying all files by hand into a new Xcode project and making all project changes again?
Not sure I understand your question, but if you just don't want the project to be a Git repository, you can simply delete the .git folder located in the project's root.
if you hasn't shared your commits with others yet, please use "git reset -mixed" or "git reset -hard" to set master to the last changes you want.
if you want to change index and working tree, use something like: git reset -hard HEAD^
if you want to change index only and keep your Xcode as uncommitted , use something like: git reset -mixed HEAD^
see man git reset

removing local git repositary from Xcode Project?

I had selected local git repositary when I created xcode Project.
But when import to SVN and commit, it commits locally not in SVN.
How can I resolve this problem? I want to remove all hidden local git files from the Xcode project without affecting source code? any help please?
Open Terminal and Type
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
open the project in finder
delete the .git
Good to go. Enjoy
Open the folder the project is in, hold down Cmd, Shift, . (period) and you will see a folder named ".git". Delete that folder, and you're good. Hide hidden files again by holding down Cmd, Shift, . (period)
You can find the solution in this question:
How to fully delete a git repository created with init?
You really should try google first before asking on SO.
The local git repository is stored in a folder named .git inside your project folder. It's hidden (any file/folder starting with a . is) but you can delete or move it using the Terminal. Once it's gone, your folder will no longer be recognized as having a git repository.

Resources