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.


git init

cat > .gitignore <<EOF

git add .

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

Explore posts in the same categories: Uncategorized

Tags: , ,

You can skip to the end and leave a response. Pinging is currently not allowed.

4 Comments on “Speeding up a Cocoa Project Repository Setup with Git”

  1. Patrick Says:

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


    • Ajat Says:

      Dear Steve. My name is Mareda, and Im working as a rereasch for a googleb4s book. Im in Spain and I had see your blog, where you have many interesting information about work in google.I would like send you any cuestions, if you dont mind. It could be an interesting testimony.

  2. Jose Lobato Says:

    Clever idea for efficiency!!! I’ll take it!!!🙂

  3. Lizzie Says:

    Your site’s design looks ugly. You schould change
    it. Better graphics means a lot more conversions, faster load and greater confidence of
    visitors. This is something that can be useful for you, search in google:
    Juicklor’s templates source

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


Get every new post delivered to your Inbox.

%d bloggers like this: