简体   繁体   中英

iPhone: How to re-create XCode built-in git repository?

I want to use git in XCode for iPhone app development.
I began to use it from few days ago.

But after renaming XCode project name, commiting doesn't work anymore.

So I tried re-create repository of git.
I could delete old repository and could create new repository with XCode's Organizer.

But I don't know how to use new repository from the project.

Having just renamed my project, this was an interesting question :)

I called up the commit dialog, and everything looked good, but on committing, I got the same problem. It looks like the project name doesn't add the new project directory to git. ( You did change the project name through Xcode didn't you, if you didn't, I'd rename it back and then change it through Xcode.)

First of all, since you've rebuild the repository, I'll address your problem.

The chances are that the problem is that the project is not added to the repository. If you have '?' marks next to your files, you just need to do a Source Control | Add for the files ( and the project) in the File Browser.

If this doesn't fix it, you may have the old project name checked into the repository ( I don't know if delete from Xcode really deletes the old repository or just unregisters it. I had this problem and fixed it from the command line

cd <project directory>
PATH=$PATH:/Applications/Xcode.app/Contents/Developer/usr/bin/
git rm <old project name>.xcodeproj

That last command gave me an error, but did seem to remove the offending entry from the repository.

Hopefully, you'll be up and running now.

I fixed the problem by working on the old repository, so what I did is for other people in a similar position.

( This is mostly command line stuff) // In Xcode, add the project to git: right click on the project in the files browser and source control|add. This should make the ? go away.

// Add the git directory to your path
PATH=$PATH:/Applications/Xcode.app/Contents/Developer/usr/bin/
// go to your project directory, for me that was something like
cd ~/Projects/<project name>

git rm <old name>.xcodeproj

git commit -m "<commit message"

There were a couple of source files that didn't commit, so I committed them with right click on the file and committing them on their own. Once I had a clean project, I made a change to one file and then did a commit through the file menu to check the complete project was committing and it was.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM