简体   繁体   English

在Xcode 4中如何将项目与我设置的本地Git存储库相关联?

[英]in Xcode 4 how to associate a project to the local Git repository I set up?

in Xcode 4 how to associate a project to the local Git repository I set up? 在Xcode 4中如何将项目与我设置的本地Git存储库相关联?

That is: 那是:

  • I've set up a Git repository after the Xcode 4 project was already created, based on instructions here : 我已经成立了一个Git仓库中的Xcode 4的项目已经创建后,根据指示在这里
  • I've gone to Organizer and "added" this as a local Git repository 我去了Organizer,并将其“添加”为本地Git存储库
  • When I go to my project in Xcode 4 the source code functions still don't appear to work - I'm guessing it because there must be some way of tying the Xcode Project wiht the local repository I created? 当我在Xcode 4中进入项目时,源代码功能似乎仍然无法正常工作-我猜是因为必须有某种方法可以将Xcode项目与我创建的本地存储库绑定起来?

From " How to Create Git Repos for Existing Xcode Projects ": 摘自“ 如何为现有的Xcode项目创建Git存储库 ”:

UPDATE: Apparently just initializing an empty repository in the project directory is enough; 更新:显然,仅在项目目录中初始化一个空的存储库就足够了; Xcode autodetects it for you. Xcode为您自动检测到它。
It be nice if something to that effect was in the documentation. 如果文档中有达到此目的的功能,那就太好了。 Thanks to Jason for that ( details here ). 感谢Jason的帮助( 此处有详细信息 )。 Open the project directory in a terminal and type the following: 在终端中打开项目目录,然后键入以下内容:

git init
git add .
git commit -m "Initial commit"

So in your case, it should detect it. 因此,在您的情况下,它应该检测到它。

The OP Greg comments: 格雷格将军评论:

I found out that all I had to do was change a file, and then the Xcode 4 pop up menu for the file did show a source control set of options (previously greyed out) . 我发现我要做的就是更改文件,然后该文件的Xcode 4弹出菜单确实显示了一组源代码控制选项(以前是灰色的)
So the initial part of the answer is correct re the manual git commands for creating the git repository. 因此,答案的最初部分是正确的,有关创建git存储库的手动git命令。


Otherwise you can try: 否则,您可以尝试:

  • make a new XCode4 project with a(n empty) git repo in it 制作一个新的XCode4项目,其中有一个(n空)git repo
  • move your .git directory and override the Xcode 4 project .git 移动您的.git目录并覆盖Xcode 4项目.git
  • move the sources in that new Xcode 4 project directory 将源移动到新的Xcode 4项目目录中
  • see if XCode4 then detect your sources and the Git integration 查看是否XCode4然后检测您的源 Git集成

Not your case probably, but one of the comments mentions : 可能不是您的情况,但是其中一项评论提到

If you're switching from an SVN repository (which I was), the trick is to go into your project folder and delete or rename the .svn directory. 如果您要从SVN信息库切换(我以前是),诀窍是进入项目文件夹并删除或重命名.svn目录。
For me it seemed that Xcode would find the .svn folder first (or preferred it, even though the backing repository was decommissioned), but once it was gone Xcode would happily start using the git repository. 对我来说,似乎Xcode会首先找到.svn文件夹(即使后备存储库已停用,还是更喜欢使用它),但是一旦消失,Xcode会很乐意开始使用git存储库。

That was actually the issue for another Xcode 4 Git user here on SO . 这实际上是另一个Xcode 4 Git用户在SO上遇到的问题

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

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