Friday, 31 August 2012

Turning on "git" when half way through an Xcode project.

The git source control system is installed within Xcode or possibly it was in OSX already. 
If you want a git repository and you did not install git as part of the process of creating your Xcode project, you may want to do the following from the command line.

You want to initialise git on your project but exclude the userstate files as they just change all the time regardless of any code changes and would just clutter stuff up and take git ages to look at.
cd to the folder where your project is. 
Look for your .xcuserstate file and echo it by name to a file called .gitignore. Alternatively use some other method to  create a file in your project folder called .gitignore with the relative path information for the .xcuserstate file. (Just in case you did not know, files with names starting '.' are invisible in the filer). "find ." will do a recursive listing of your folder and using "grep" will filter the file you want. This is done as follows. (Stop Xcode first, it is good enough at crashing without providing it with excuses!).
(In the root of your XCode project folder) (Some of this is pasted small to get all on one line)

cd Developer/HP11/

find . |grep xcuserstate

Then echo it to make the file .gitignore. The following up to and including >.gitignore is all one line.

echo HP11.xcodeproj/project.xcworkspace/xcuserdata/brian.xcuserdatad/UserInterfaceState.xcuserstate >.gitignore

Then, initialise your git repository and do the first commit.

git init
git add .
git commit -m "First commit"
git config --global "Author Name"
git config --global
git commit --amend --reset-author
git commit --amend --reset-author

Just type "git" to get other git options from the cli.
From here on in you should be able to use the File>Source Control >Commit menu within XCode.

Using source control allows you to roll back to earlier versions and see and (from your comment) understand exactly what changes you made. 

This site  has a good description of all your git options.

No comments:

Post a Comment