Suddenly, unfortunately, I can't place the moment of occurrence Xcode has stopped showing git information, nor can I submit/revert/etc via git from inside Xcode. If I check the Organizer's Repositories, my project is still listed with its last commit.
Using the command line: git status, I see all the unstaged changes as I would expect.
So, the project is still under git control, but somehow detached from Xcode.
I was able to fix this issue by going to Organizer in Xcode, selecting my project, and deleting the Derived Data. You may need to quit Xcode and re-open your project after doing this to let Xcode rebuild the project index.
Installing the command line tools worked for me
Related
In My xcode project, Throught sourceTree, I reset all the uncommited changes, is there any way to get it back from git or xcode?
Not probably via git but via xcode , i believe xcode keep local history found a blog https://codeforfun.wordpress.com/2015/09/30/xcode-local-history/ can check if this works.
Problem:
When I hit "Commit..." under the Source Control menu in Xcode, the window comes up blank and I get a colorful pinwheel that doesn't stop spinning, so I have to force quit Xcode.
Details:
It's not a problem with Xcode in general because I can still commit other projects.
The version editor still works (I can still see previous commits I've made).
I've let the pinwheel run for over an hour, and still nothing happens.
I was able to commit this project up until a couple months ago. Since then, I added a few files to it, edited it a bit, updated Xcode if I remember right, and updated macOS.
Some of the files I added came from other projects.
I've tried removing some of the files I added and then committing, but that didn't work so I added them back.
I've tried cleaning the project, restarting Xcode, and restarting my mac.
I don't know much about source control, but I don't have anything fancy set up with a team or anything, it's just a local repository.
I've tried suggestions to delete various things inside the .xcodeproj file, to no avail.
I have Xcode 9.4.1
Any ideas?
If you have added big files (larger than 100mb) then sometimes Xcode has trouble with them. Try unstaging your commits and then committing them again. Finally try reverting back to the most recent version of your project and working from there.
I had the same problem. Sometimes selecting "Fetch and refresh status" works. The next time you go to commit the files will show up.
I found that rebooting my computer fixed the problem.
I'm just starting to learn Swift using the Apple Xcode IDE. I made a little test iOS app and was trying various things when I inadvertently deleted my main code file (ViewController.swift). "No problem", I thought, as I had hit "Save" just a couple of minutes before. I exited out, then came back in, but it appeared to have autosaved.
I don't really care about this test file, but am wondering what is the proper way to save a project before trying something out (or before inadvertently pulling a bonehead move)?
What happens when I “save” in Xcode IDE?
When you hit "Save" the changes you've made are saved to disk. XCode doesn't do this automatically. If it crashes you may lose all your code written after the last time it was saved to disk. But XCode saves the changes to disk even without hitting "Save" button in some cases.
Xcode automatically saves changes to source, project, and workspace
files as you work. This feature requires no configuration, because
Xcode continuously tracks your changes and saves them in memory. Xcode
then writes these changes to disk whenever you:
Build and run your app
Commit files to a source code repository
Close the project
Quit Xcode
https://developer.apple.com/library/archive/documentation/ToolsLanguages/Conceptual/Xcode_Overview/UsingFileSaving.html
Use Git. If you don't know what it is, look into it. In the mean time, here is a tutorial or two.
To use it in Xcode, when you create a project, be sure to create a git repo:
Then be sure to commit frequently. Xcode has a built in Git GUI, so that makes it easier:
Then if you do anything that you shouldn't have you can either discard all changes (see the above screen shot, or if that can't help you, you can:
Open the 'Terminal' app
cd to the directory with the project
Run git log
Find the commit before you ruined everything
Copy the commit hash
Type q to exit the log
Run git reset --hard <THE-HASH-YOU-COPIED>
That should do it for you.
When creating a project check 'create git repository on my mac'.
Then commit changes when you're finished with one minor part and give the commit a comment so you know when looking into the history what changes you have done (quick overview).
With git you can quickly revert changes and go back to certain revisions like you can do in TimeMachine.
Further information are available at git's webpage.
I am a new programmer and trying to use Xcode's source control manager to keep track of changes to my code.
Right now I would like to revert back to a previously committed version of my project. However, in opening the Organizer, selecting Repositories, and selecting my project from the left project list, I can only see snapshots of my project.
The previously committed versions appear correctly when using the Version editor outside of Organizer.
Ideas?
I don't believe you can do this within Xcode but it is simple enough outside of Xcode. The easiest approach would be enter the following in Terminal:
git checkout -b <new branch> <commit>
This won't revert on the current branch but will give you a new branch to develop off of. If you really want to revert then simply:
git revert <commit>
with conflict resolution will work.
If you can't find 'git' within the Terminal then 1) install the Xcode command line tools or 2) look in the Xcode package under Xcode/.../usr/bin to find it.
I have created a new project and checked the "create a local git repository" option. I opened the organizer to check that there is a repository for my project and it was there. I made some changes on some files, and noticed the source control specific letters "A" .. "M" beside them, but when I choose: File-> Source Control -> Commit, I get the following message from XCode 4.2:
the operation could not be performed because no valid working copies were found
Please verify that your files are under source control and try again
However, I opened the organizer again, and noticed that the repository of my project includes three icons on the left bar: Branches, Remotes and a folder with the same name as of the project. I chose the last one (the folder) and pressed the Commit button on the bottom bar of the organizer. The commit sheet opened and I performed the commit successfully. Now, when I close the organizer, and edit some files in my project, I do not see the source control specific letters "M" ... "A" ... beside each modified file.
My problem is about two points:
1) Why can't I commit from File->Source Control->Commit menu option
2) When I commit from the repository itself, and go back to the project and edit some files, why do not I see source control letters beside modified files?]
For what it's worth (and as #Jahelia's comment mentions), this seems to be a bug in XCode 4.2 when it first engages with git. The workaround seems to be to at least close Xcode and reopen. (If that doesn't work, try opening and closing the organizer.)
I encountered this myself today when trying out Git with Xcode for the first time. I created two demo projects with the "create a local git repository" option and they had the same problem. I was able to commit from the organizer window, but the main Xcode file view didn't seem to recognize git at all.
After quitting and restarting, I created a third demo with the git option, and the main window recognized the changes (after building) right off the bat - i.e showed the "M" beside a modified file.
I've experienced and recovered from this.
I can't tell you what causes it but, notably, in the "Repositories" view in my Organiser, I had TWO similarly-named repositories. What differed about them was the case of one of the paths.
One was "~/Work/Code/Bumhole" and the other "~/work/Code/Bumhole".
I caused the problem by XCode crashing during a commit to the repository (of many changes).
I fixed the problem by
closing the offending project
closing Xcode
rebooting
reopening Xcode
(close the project if its open)
open the Organiser view
Select the "bad" repository and delete it with backspace
Navigate the remaining "good" repository until you see the .xcodeproj file
Double click the .xcodeproj file to open the project
I expect this list is a superset of the steps needed to fix the problem, but this worked for me.
If your project is in /Developer/.... move it elsewhere and reopen the project. This may resolve your problem.
There seems to be a problem under Xcode 4.2 with projects in /Developer/... and git integration (you get the error "The operation could not be performed because no valid working copies were found. Please verify that your files are under source control and try again")
This bug still exists in Xcode 4.6.3 and when using Subversion.
I know this has already been answered but this worked for me:
Open terminal
cd yourprojectdirectory
git config --global user.email "youremail#email.com"
git config --global user.name "username"