« Truth Table for C4[2] shirt | Main | The Cross-Platform Drobo Conundrum »
Thursday
Oct232008

Speeding up a Cocoa Project Repository Setup with Git

I just finished working my way through a chapter of a new iPhone dev book. I had a working copy of the example of the book and felt like mucking around with it to learn more on my own. I still want to keep the original state of the code, but I am too lazy to setup a repository for such "disposable" code.


Years of using Subversion have made me lazy like that. I am really lazy. I always forget what the steps are to create a repo, mostly because it is usually such an infrequent task for me. But now that Git makes it so easy to create a repo right there in the project directory I'm working on without littering the whole thing with junk... hmmm... Maybe I should be using it even for "disposable" code.


So to facilitate this new behavior I wrote a little script. It expects the root of the project to be the current working directory, so make sure you "cd" into the right place before invoking it. Here is what it does:



  1. Creates a new new git repository at the CWD

  2. Creates a new .gitignore file to ignore:
    • the build directory

    • user.pbxuser file inside the project

    • user.perspectivev3 file inside the project

  3. Adds all the files in the CWD to the index, staging them for inclusion in the next commit

  4. finally commit everything with the default message "- initial commit to Repository"


I think this will be useful to me, and so I post it here in case it is useful to others. It is really very simple. Please let me know if you have any suggestions to improve it.



#!/bin/bash

git init

cat > .gitignore <<EOF
build
.xcodeproj/.pbxuser
.xcodeproj/.perspectivev3
EOF

git add .

git commit -a -m "- initial commit to Repository"


PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments (1)

Thank you very much for this handy little script. Should save quite some time when working on new projects.

Greetings

October 29, 2008 | Unregistered CommenterPatrick

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>