Committing source to git via Xcode, failure to commit - xcode

I have a repository, in which i code. Once some changes are made, they are checked in to GIT repo via Xcode.
Before checking in .. files look like this - files i have changed look right
Upon checking the code in (Alt-Command-C), all i see is (Note that files seen in explorer window are not seen)
Towards the bottom of the screen, correct number of files are shown
When commit button is hit, no errors are shown, all looks normal, however, nothing (visually) changes:
Explorer continues to show same files modified
Commit screen continues to show some files in need of being committed
Commit screen does NOT show exact files to be committed
I could have sworn that last night all files were committed. Could someone help me understand what's going on here?
UPDATE:
After modifying my .gitignore to include
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
*.xcuserstate
project.xcworkspace/
xcuserdata/
.DS_Store
*.tm_build_errors

You should probably create a .gitignore file and put it in your directory. The xcuserstate files are constantly changing (and are of no use to your overall commits). Your will always show changes and it will also prevent you from pushing your changes to your remote (if you have one).
There are plenty of places that will show you how to make a good gitignore file.
Git ignore file for Xcode project

The issue it seems was that in my set up, Xcode defaults to File View
When I switched to Flat View, files which were changed showed up

First thing to try it to try to commit the files from the command line.
Run git status to see the state of things, git add <modified files>, and the git commit - you should either see an error or files will be committed.

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.

Cannot save changes in file under Git version control

I forked and cloned a project from GitHub and I can make changes to all files but one.
It's .xml. When I make changes and hit the save button, the file reverts back to its original state.
I've done git config core.fileMode false but to no avail. I've also checked the file permissions and it's -rw-r--r--. Same as other files I can edit.
Please, how can I solve this problem?
The last time, I had to go to Git web and make the changes there before pulling.
I realized the file I was editing is in a directory in the .gitignore.
So maybe git was undoing the changes I was making.

I have deleted my project.pbxproj file using git checkout -- <file>. Should I delete the branch locally and pull from origin?

I have gotten myself into some hot water regarding source control.
I had just gotten a feature branch to work that another developer on my team had created and developed, which required adding some files. He then added some additional code to the project, and I wanted to revert to the version of the branch I had started with before I pulled his new code so that I wouldn't have to worry about merging these new files.
So, as per git's recommendation, I unstaged the changes I had made and used:
git checkout -- ScrollingTextLabels.xcodeproj/project.pbxproj
followed by:
git pull
I had assumed that the pull would replace the project.pbxproj file with the one from the origin, but instead git spat out a lot of lines beginning with "delete mode", most disconcertingly:
delete mode 100644 ScrollingTextLabels.xcodeproj/project.pbxproj
Every time I try to open the project on this branch, I now get the following error message from Xcode:
Project /Users/myname/Documents/Code/organization/product-ios/ScrollingTextLabels.xcodeproj cannot be opened because it is missing its project.pbxproj file.
I have been able to switch to other branches, which are still working fine, and must have their project.pbxproj file.
Also, I attempted to use git reset --hard to no avail. Should I force an overwrite (a la How do I force "git pull" to overwrite local files?)?
Should I delete the branch locally and pull from origin?
All I want is for the remote version of this branch, which is working well, to appear unchanged on my computer so that I can open it and continue working.
The message
delete mode 100644 ScrollingTextLabels.xcodeproj/project.pbxproj
during a merge (or pull) indicates that the file was deleted in the to-be-merged branch. It does not exist anymore in the other branch, your co-worker must have deleted that file.
Deleting a branch and pulling does normally not solve anything. You already have all changes from the remote (probably in origin/branch). Either checkout a new branch from that commit, or reset to it (potentially losing all your local changes!)
Use git log origin/branch or gitk to view the changes of the branch. You can also show the log for this single file only with git log origin/branch -- ScrollingTextLabels.xcodeproj/project.pbxproj. This should tell you, what happened to the file and whether it was deleted in the branch.

xcode commit missing file or directory

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.

Preventing certain things from being committed in XCode

Situation: I have a few things in my code repository that I only want to be in my own working copy, but I still want to be able to modify the rest of the codebase and do commits without putting in those certain things I mentioned. Is it possible to lock those down in some way so they do not go in with the rest of my commit? Right now XCode commits everything that was modified. I realize I could commit files individually but it would be nice to continue to use the global commit.
Why not try the svn:ignore property (about half-way down the page)?
Maybe you could change the status of files to locked, then commit them without locked files.
For SVN help, pls reference to http://svnbook.red-bean.com/en/1.5/index.html.
You should comment in "global-ignores" line in the configuration file located in ~/.subversion/config.
By this way you could ignore file types that you have given. I use the following set:
global-ignores = *.o *.lo .la ## .*.rej .rej .~ ~ .# .DS_Store *.mode1v3 *.pbxuser
Hope this helps.

Resources