Git, Xcode and ProjectLocker

Here is a checklist for setting up git for Xcode projects on a Mac.

1- install

Install Git from git-osx-installer

Install Gitx from gitx

Launch Gitx and invoke Enable Terminal Usage form Preferences

Read up the git basics

2- set up git for an Xcode project :

cd <projectdir>

git init

This creates the subdirectory .git

git status

Create file .gitignore :

#see http://shanesbrain.net/2008/7/9/using-xcode-with-git
# xcode noise
build/*
*.xcclassmodel/*
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3

# old skool
.svn

# osx noise
.DS_Store
profile

Create file .gitattributes :

#see http://shanesbrain.net/2008/7/9/using-xcode-with-git

*.pbxproj -crlf -diff -merge

We could continue in Terminal using git commands (add, commit)

but we can now launch Gitx from Terminal :

gitx

This opens the GUI view on files to be added and comitted – see the gitx documentation for details.

Use gitx to add all Xcode files in the project and to commit them.

3- create a remote repository at ProjectLocker

Sign up at ProjectLocker for a free account (git)

Generate a public key with

ssh-keygen -t dsa

and paste it to ProjectLocker when requested.

ProjectLocker will provide a Git Location similar to git-your_user_name@free2.projectlocker.com:your_first_project_name.git

Back in Terminal in the Xcode project directory, tell git about the remote location, then pull the (for now empty) remote repository, and finally push the local repository :

git remote add origin git-your_user_name@free2.projectlocker.com:your_first_project_name.git

git pull origin master

git push origin master

Now the remote repository should contain a copy of the local repository.

4- add projects to the ProjectLocker (PL) repository

You need to create a PL project for each local git project that you want to replicate to the PL.

You log in to PL and Add Project … very simple.

Just don’t forget to add yourself as User to the newly created project, otherwise you won’t have the access to it from your local terminal via git.


Advertisements

9 thoughts on “Git, Xcode and ProjectLocker

  1. First, just wanted to say thank you for the informative post. I just recently purchased a PL account. Do you have any advise for cloning the repository from a remote server (access to the remote server is via SSH)? Is it the same process as you described above or is there a different process?

  2. Eric,

    I can clone a remote repository using the Terminal on Mac like so :

    $ mkdir directory_for_the_clone
    $ cd directory_for_the_clone
    $ git clone git-your_user_name@free2.projectlocker.com:your_project_name.git

    Now you should find the cloned files in your directory.

    AFAIK, Git and ProjecLocker use SSH for this operation, but I don’t have to invoke SSH directly.

  3. I was logging into a remote server via ssh. While on that remote server I was trying to perform a git pull; however, I was always getting a time out error. Finally, I called my hosting company and they were able to open the port that was needed.

    So I was then able to perform the git pull from the remote server. This is just an FYI in case any one else encounters this issue.

  4. what’s the meaning of origin and master ? you said about “origin master”

    is origin means repository on the internet and master repository on my local storage ?

    1. advin,

      Yes, you are correct : ‘origin’ is the remote repository (on ProjectLocker in my case) and ‘master’ is the git main branch on my local computer.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s