chinjazz
chinjazz

Reputation: 135

Convert Xcode project to New Xcode 4 with Git and enable .gitignore?

I'm sort of stumbling around with an issue with Xcode 4, and Git. I'm a one man shop with multiple macs, and had my project working with Git and Xcode4, (stored on a dropbox folder), so I could share that folder across my MBP and iMac with minimal interaction. So, it was late one night and I accidentally committed my xcode project file, and then I started getting issues with UserInterfaceState.xuserstate constantly updating... Later learned that .gitignore would have been good to have in place.

Back to the drawing board and I've been trying to take the new (old) project and enable git on it with the following: $cd path/to/project $git init $git add . $git commit -m "Initial commit of project"

This works fine, now I'm back in XCODE, and add the repository, which it recognizes in Organizer. One Issue is XCODE doesn't recognize that I've modified a file, and the majority of the "Source Control" menu items are disabled, Ex: "Commit"

I'm wondering if there are a recommended # of steps to:

1) Get Git running on a xcode project that wasn't set up this way initially 2) Steps to add the Gitignore file and when

I'm obviously learning some Git SCM related items with xcode 4, and I appreciate your feedback!

Upvotes: 2

Views: 1930

Answers (3)

Paul Cezanne
Paul Cezanne

Reputation: 8741

Maybe this isn't the answer you want but I gave up on getting Xcode4 to play well with git and just started using the excellent (and free) SourceTree. It really made my life easier.

Upvotes: 5

Abizern
Abizern

Reputation: 150615

There are three ways of setting up exclude files in git. Which is easiest depends on you. But, I find that when using git to share for myself amongst multiple machines, a global ignore file works best, and I can always add more specific excludes if you need to.

Essentially

  1. Globally, by setting up a per user or per machine exclude file
  2. Per repository - by setting up a .gitignore file in the repo
  3. Per clone - by setting up the `.git/info/excludes file

I've got a my global exclude file on Github if you want to see an example, including Xcode4 specific exclusions.

Upvotes: 1

EasyCoder
EasyCoder

Reputation: 503

To add Git to the project

  1. Go to the directory and in a terminal window

    cat > .gitignore
    build/*
    *.pbxuser
    *.perspectivev3
    *.mode1v3
    javascripts/phonegap.*.js
    

    Type Ctrl+D to close the file.

  2. Initialize the Git repository

    git init
    git add .
    git commit -m
    
  3. Add the repository in organizer. Use the full directory path.

Caveat - this still does not enable Source Control menu items. But you can use git from the command line. See other related post: Using Git with an existing XCode project

Upvotes: 2

Related Questions