boostedz06
boostedz06

Reputation: 319

Xcode iOS using git

I have set up a bitbucket repo and have configured it in my Organizer. I have created a basic .gitignore and added it to the root of my project. I have tried committing all the files, but it continues to say there are uncommitted files when I try to push.

The uncommited files are:

I have already put *.xcuserstate in my .gitignore.

Any ideas?

Upvotes: 4

Views: 1591

Answers (4)

Bill Burgess
Bill Burgess

Reputation: 14154

I used to have this same problem all the time.

First, close Xcode. This will only continue to generate the xcuserstate changes that will keep coming up. Open up your project folder, we need to get the userstate outta there. If you right click your .xcodeproj file, select Show Package Contents. This will allow you to see everything hiding in there. You can delete the .xcuserdata file there. This may lose your Xcode state, like which folders you had opened, tabs, etc. But it shouldn't hurt your project in any way. It will just create another one next time you open Xcode.

Next, open up Terminal. This is the best way to handle this issue. Make sure you are in the directory of your project inside terminal. If you aren't sure, type cd and drag and drop the project folder into Terminal to load the location name.

rm .DS_Store

This will delete the hidden folder file Mac OS creates. Don't worry about it. Close the project folder if you haven't already, or it will just create another one.

Hopefully if you've gotten this far, you can run git status in terminal on this current setup and should see a message showing just the 1 file left to commit. The pbxproj file. If so, great!

git add project.pbxproj
git commit -m "Put some commit message for this file"

This should add your project file and commit it git and clear things up. A git status should show your repo is free and clear of all your untracked and uncommitted files.

With any luck, when you fire up Xcode again and those files get created, your gitignore file should kick in and ignore them for future commits. This used to happen to me a lot when I first started with git. I finally learned to check the ignore file in first before adding any Xcode source files. Hope this helps.

Upvotes: 2

Daniel
Daniel

Reputation: 23359

It looks like you added these files to the repo before you set up your gitignore.

You will have to remove them completely first - check out this post: Ignore files that have already been committed to a Git repository

I usually have the following:

.DS_Store
*.log
xcuserdata
build/*
.svn

Well svn is just because there's some version control mix happening, and the build folder is not necessary as of Xcode 4.4 I believe - this version stores the builds somewhere else, but you can override that if you want to. It's good to keep that in.

project.pbxproj is actually your project file, you need this although it will become annoying if you are in a team as other developers change their code signing profiles in the project - tip: iOS team provisioning profiles are your friend.

Upvotes: 1

Simon Germain
Simon Germain

Reputation: 6844

You'll have to delete the file from the repository and commit the delete for the .gitignore file to start ignore it. It won't ignore files that are already present.

Upvotes: 1

Marco
Marco

Reputation: 6692

Here is my .gitignore file (do not ignore project.pbxproj):

.bundle
db/*.sqlite3
log/*.log
tmp/
.DS_Store

Upvotes: 0

Related Questions