When I started my project I used Git in the terminal to track changes. Then I realized source control is built into Xcode. So I committed all my changes, everything worked well. Then I went to history in Xcode and saw all my previous commits made from the terminal.
How does Xcode know about those commits? Especially since I haven't signed into my Git repo in Xcode.
The Git history is kept locally in the project's .git folder. When you open Xcode, it finds your local .git folder and uses it to show the project's history.
You don't have to push to your remote Git repo for that, since the history is kept locally.
Related
I am using Xcode to as my IDE for coding questions that I publish and commit to my GitHub account. However, I don't want the ProjectName.xcodeproj to be shown in the repo. Is this possible?
Also, how do you suggest managing .gitignore files in Xcode? The only solution I have come across is managing it manually via terminal.
I've tried creating a .gitignore file via gitignore.io and then going into the project directory via terminal and using curl http://gitignore.io/api/c++,xcode > .gitignore. This has no effect whatsoever.
This has no effect whatsoever.
This would have no effect if the files listed by the .gitignored are already tracked.
Try (now that you have a .gitignore in place) git rm --cached -- ProjectName.xcodeproj, and then see if that file is still in XCode Git status.
Commit and push: that file won't be in the repository anymore.
I want to get rid of the link to the git repository
As you can see below clicking on source control still shows the old git remote.
I was using both SVN and Git, Xcode was configured with GIT.
What I did was
delete .git/ in Terminal.
Delete Git Repositories from XCode preferences
Add SVN Repository to Xcode Preferences.
Check out a new working copy Using Source Control - Checkout
I have tried adding a new git and setting the remote or deleting it.
What I have done is manually edit the files
.xccheckout
.xcscmblueprint
Which were located in .xcworkspace I found these by grepping
grep -wr git *
I deleted every key value which had git in it.
I am not sure whether I left some superfluous data in it, but so far it seems to be holding up.
As you can see the git part is gone and only my svn remains
I have a project I started with Xcode 3.0. Back then source files were stored in the root directory by default. A long time ago I even did this. Things have evolved, both the project and Xcode and I now have a curious situation:
I have a root folder with the .xcodeproj folder used by Xcode and a ton of old source files I will not use again. More recent versions of Xcode have created a similarly named folder where more recent source files exist.
I'd like to clean up my repository. What should I do with the files I am no longer using? Move them to a separate folder? hg rm? Checkout the repository anew but from a specific revision?
Just do hg rm, files will be moved out of way but kept in the history. That's the very reason why version control exists. Should you ever need them in the future, checkout a past commit and they will be back.
I am using git in my projects, whenever I try to pull from Xcode I get "Uncommitted Changes" and it prevents me from pulling/pushing.
I try to commit and find one file with extension *.xcuserstate, this file is modified whenever I open/scroll into any project file in Xcode. That leaves me no option but to do a single commit that contains that file, which fill the git commit logs with meaningless commits.
Is this there is a way to stop this behavior?
I tried to put *.xcuserstate and xcuserdata into git ignore but that caused Xcode to crash every time I try to pull.
This happens with Xcode 4.2 and 4.3
Normally you don't want to put the *.xcuserstate and *.xcuserdata files into your Git repository. These files aren't really part of your project, but are just a place where Xcode stores its local information that is helpful when reloading your project.
You can fix this by using:
git rm --cached *.xcuserstate *.xcuserdata
and then committing the result. This will remove those files from the repository without removing them from your working directory.
If this is a settings file which is different for every developer, you probably don't need to version control it, just remove it from Git.
If that is not an option, you can Git Stash Save your changes before pulling and Git Stash pop to apply them again.
in Xcode 4 how to associate a project to the local Git repository I set up?
That is:
I've set up a Git repository after the Xcode 4 project was already created, based on instructions here:
I've gone to Organizer and "added" this as a local Git repository
When I go to my project in Xcode 4 the source code functions still don't appear to work - I'm guessing it because there must be some way of tying the Xcode Project wiht the local repository I created?
From "How to Create Git Repos for Existing Xcode Projects":
UPDATE: Apparently just initializing an empty repository in the project directory is enough; Xcode autodetects it for you.
It be nice if something to that effect was in the documentation. Thanks to Jason for that (details here). Open the project directory in a terminal and type the following:
git init
git add .
git commit -m "Initial commit"
So in your case, it should detect it.
The OP Greg comments:
I found out that all I had to do was change a file, and then the Xcode 4 pop up menu for the file did show a source control set of options (previously greyed out).
So the initial part of the answer is correct re the manual git commands for creating the git repository.
Otherwise you can try:
make a new XCode4 project with a(n empty) git repo in it
move your .git directory and override the Xcode 4 project .git
move the sources in that new Xcode 4 project directory
see if XCode4 then detect your sources and the Git integration
Not your case probably, but one of the comments mentions:
If you're switching from an SVN repository (which I was), the trick is to go into your project folder and delete or rename the .svn directory.
For me it seemed that Xcode would find the .svn folder first (or preferred it, even though the backing repository was decommissioned), but once it was gone Xcode would happily start using the git repository.
That was actually the issue for another Xcode 4 Git user here on SO.