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
- Ultimately would like the "Source Control" menu items enabled again.
I'm obviously learning some Git SCM related items with xcode 4, and I appreciate your feedback!
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.
To add Git to the project
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.
Initialize the Git repository
git init git add . git commit -m
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
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
- Globally, by setting up a per user or per machine exclude file
- Per repository - by setting up a .gitignore file in the repo
- 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.
精彩评论