简体   繁体   English

iPhone:如何重新创建XCode内置git存储库?

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

I want to use git in XCode for iPhone app development. 我想在XCode中使用git进行iPhone应用程序开发。
I began to use it from few days ago. 我从几天前开始使用它。

But after renaming XCode project name, commiting doesn't work anymore. 但是在重命名XCode项目名称后,提交不再起作用。

So I tried re-create repository of git. 所以我尝试重新创建git的存储库。
I could delete old repository and could create new repository with XCode's Organizer. 我可以删除旧的存储库,并可以使用XCode的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. 看起来项目名称没有将新的项目目录添加到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.) (您确实通过Xcode更改了项目名称,如果没有,我将其重命名,然后通过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 | 文件旁边的标记,您只需要执行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 如果这不能解决问题,则您可能会将旧项目名称签入了存储库中(我不知道从Xcode中删除是否真的删除了旧存储库或只是注销了它。我遇到了这个问题,并从命令行对其进行了修复

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. (这主要是命令行内容)//在Xcode中,将项目添加到git:在文件浏览器中右键单击该项目,然后单击源代码控制| 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. 有了干净的项目后,我对一个文件进行了更改,然后通过文件菜单进行了提交,以检查整个项目是否正在提交。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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