Friday 23 September 2011

Git Source Control with Xcode

Finally got this working after some issues. In the end I found the easiest way was to leave Xcode out of the creation of the repository (I was adding to an existing project).

If you're not a terminal wizard you may find it helpful to enable viewing of hidden files on your mac by typing the following into terminal:

defaults write com.apple.finder AppleShowAllFiles -bool true

This let me get a good look at all the .git folder files. Turn it off by calling the same command with false at the end rather than true.

Git isn't too difficult once you know what you're doing. I started by navigating to the folder I wanted source control for (in my case this was not the entire Xcode folder as it contains lots of other data, I only wanted code to be source controlled) and use the following git commands.

git init
git add .
git commit -m 'First commit'

This creates a git repository in the folder, adds all the files in the folder and writes a first commit with a comment. Next I added the remote copy 'origin' and pushed the local git repository to my master version on a server.

git remote add origin
git push origin master

I now use Xcode to commit changes to my local repository and simply push to the server using the above git command.

No comments:

Post a Comment