使用Xcode将现有项目添加到BitBucket [英] Add existing project to BitBucket using Xcode

查看:109
本文介绍了使用Xcode将现有项目添加到BitBucket的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用Xcode提交项目文件时,我总是收到错误消息.

I keep getting an error when I try to commit my project files using Xcode.

文件->源代码管理->提交

File -> Source Control -> Commit

由于找不到有效的工作副本,因此无法执行该操作." 请验证您的文件是否受源代码控制,然后重试."

"The operation could not be performed because no valid working copies were found." "Please verify that your files are under source control and try again."

这是一个不受源代码控制的现有项目.如何使用Xcode将项目文件置于源代码控制下?

This is an existing project that is NOT under source control. How do I get my project files under source control, using Xcode?

回答了我自己的问题.

第1步)重新启动Xcode

Step 1) Restart Xcode

第2步)选择连接到存储库"

Step 2) Choose connect to repo

第3步)输入回购地址

第4步)选择要放置在版本控制下的现有项目文件夹

Step 4) Choose existing project folder you wish to place under version control

第5步)瞧! :)

推荐答案

由于许多人在Google上搜索使用Xcode将现有项目添加到BitBucket中"时都落在这里,然后单击进入指向我的博客文章的链接该主题,我想我将信息放在此处(本着这样的精神,不鼓励仅链接答案).

Since a lot of folks land here when they google "Add existing project to BitBucket using Xcode" and then click through to the link that goes to my blog post on the subject, I thought I would put the information here (in the spirit of SO which discourages link only answers.)

注意:这些说明假定您已经为项目创建了本地git存储库.您可能在项目创建时就完成了此操作.如果没有,则需要立即创建本地git.请参阅此StackOverflow帖子以了解如何执行此操作: https://stackoverflow.com/questions/19495141/add-local-repo-for-existing-xcode-5-project

NOTE: These instructions assume you have already made a local git repository for the project. You may have done this at project creation. If not, you will need to create the local git now. See this StackOverflow post for how to do that: https://stackoverflow.com/questions/19495141/add-local-repo-for-existing-xcode-5-project

对于Xcode 9和Bitbucket的新Beta用户界面:

  1. 在其网站上登录您的BitBucket帐户.
  2. 单击创建"按钮(最新版本的Web UI中的加号+).然后单击存储库.
  3. 为新的存储库命名.存储库的其他功能可以在高级"菜单下配置.如果需要,请确保已选中私人"的复选标记.验证存储库类型为Git.如果需要,添加问题跟踪和Wiki.从语言下拉列表中选择"Objective C"或"Swift".然后创建存储库.
  4. 接下来,您将要添加代码. 概述"页面顶部是带有项目的HTTPS URL的字段.它看起来像这样: https://johndoe@bitbucket.org/xyzteam/xyzapp.git .突出显示并复制该URL文本.
  5. 运行Xcode并加载您的项目.
  6. 从Xcode的左窗格中,选择Source Control Navigator.展开项目节点.右键单击项目下的"Remotes"节点.选择添加现有的遥控器..."
  7. 为其提供一个远程名称,例如Bitbucket.将第4步中的URL粘贴到位置"中.单击添加.现在,它应该在源代码管理"导航器中显示为远程"位置.
  8. 一旦添加了遥控器,您现在应该可以将其推送到遥控器.选择Source Control/Push…(源代码控制/推送…).它将显示您的Bitbucket远程作为目标,并显示(创建),因为这是第一次推送.点击推送".
  9. 如果这是您第一次将此项目推送到BitBucket,将要求您提供登录凭据.用户名将从URL中预填,因此请输入密码.单击确定",几秒钟后,它应该完成.
  1. Log into your BitBucket Account on their web site.

  2. Click the Create button (plus sign + in the newest version of the web UI). And click Repository.

  3. Give your new repository a name. Additional features for the repo can be configured under the Advanced menu. Make sure the check mark for Private is on if you desire that. Verify that the repository type is Git. If desired, add issue tracking, and a Wiki. Select Objective C or Swift from the language drop down. Then Create Repository.

  4. Next, you will want to add your code. On the top of the Overview page is a field with the HTTPS URL of your project. It will look something like this: https://johndoe@bitbucket.org/xyzteam/xyzapp.git. Highlight and copy that URL text.

  5. Run Xcode and load your project.

  6. From the left pane in Xcode, select the Source Control Navigator. Expand the project node. Right click the Remotes node under your project. Select "Add Existing Remote…"

  7. Give it a remote name, such as Bitbucket. Paste the URL from step 4 into the Location. Click Add. It should now appear as a Remote location in the Source Control navigator.

  8. Once your remote has been added, you should now be able to push to the remote. Select Source Control/Push… It should show your Bitbucket remote as the destination and will show (Create) as this is the first push. Click Push.
  9. If this is the first time you are pushing this project to BitBucket, you will be asked for login credentials. The User Name will be prefilled from the URL, so enter the password. Click Okay and after some seconds, it should complete.

如果一切顺利,那么您现在已经链接了存储库.转到BitBucket网站,选择您的仓库,您应该会看到代码.

If all goes well, you now have the repositories linked up. Go to the BitBucket site, select your repo and you should see the code.

对于早于版本9和旧Bitbucket UI的Xcode:

  1. 在其网站上登录您的BitBucket帐户.

  1. Log into your BitBucket Account on their web site.

单击创建"按钮.

给新存储库一个名称,一个描述,并确保在需要时选中专用"复选标记.验证存储库类型为Git.如果需要,添加问题跟踪和Wiki.从语言下拉列表中选择"Objective C"或"Swift".然后创建它.

Give your new repository a name, a description, and make sure the check mark for Private is on if you desire that. Verify that the repository type is Git. If desired, add issue tracking, and a Wiki. Select Objective C or Swift from the language drop down. Then Create it.

接下来,您将要添加代码.我假设您有一个现有项目.在页面上,您将从命令行部分选择我有一个现有项目"链接.

Next, you will want to add your code. I am assuming you have an existing project. On the page, you will select "I have an existing project" link from the Command line section.

您将看到有关将本地git存储库链接到远程服务器的说明.无需遵循这些说明.但是,您将看到列出的https网址.它看起来像这样: https://johndoe@bitbucket.org/xyzteam/xyzapp.git .突出显示并复制该URL文本.

You will see instructions for linking your local git repository to the remote. There is no need to follow those instructions. However, you will see an https url listed. It will look something like this: https://johndoe@bitbucket.org/xyzteam/xyzapp.git. Highlight and copy that URL text.

运行Xcode并加载您的项目.

Run Xcode and load your project.

从主菜单中选择源代码管理".在灰色的工作副本"项下,您将看到一个包含本地git repo名称和当前活动分支的菜单.展开此菜单,您将看到一个配置[您的项目]…的选项.选择这个.

From the main menu, select Source Control. Under the gray "Working Copy" item, you will see a menu with your local git repo name and the currently active branch. Expand this menu and you will see an option to Configure [Your project]…. Select this.

从此屏幕选择"Remotes"窗格.在底部,单击加号+.选择添加远程...

Select the Remotes pane from this screen. At the bottom, click the plus +. Select Add Remote…

现在,您需要一个名称和一个URL.对于名称,通常只使用您的项目名称,然后粘贴先前在步骤5中复制的URL.有些人发现他们必须删除URL的用户名部分.在此示例中,删除"johndoe @".这可能与您的项目是设置为团队项目还是单个项目有关.

Now you need a name and a URL. For the name, typically just use your project name, then paste the URL copied earlier in step 5. Some people have found that they must remove the user name portion of the URL. Per the example, remove "johndoe@". This may have to do with whether your project is set up as a team project, or an individual project.

单击添加远程".单击完成.

Click Add Remote. Click Done.

添加了遥控器后,您现在应该可以将其推送到遥控器了.选择源代码控制/推送….如果这是您第一次将此项目推送到BitBucket,则可能会询问您有关钥匙串访问和/或登录凭据的信息.输入适当的响应,例如允许钥匙串".如果您以前已经完成过此操作,它将仅使用钥匙串数据,而无需进一步提示.

Once your remote has been added, you should now be able to push to the remote. Select Source Control/Push…. If this is the first time you are pushing this project to BitBucket, you may be asked about keychain access and/or login credentials. Enter the appropriate responses, such as Allow for keychain. If you have already done this before, it will simply use the keychain data without further prompting.

如果一切顺利,那么您现在已经链接了存储库.转到BitBucket网站,选择您的存储库,您应该会看到代码.

If all goes well, you now have the repositories linked up. Go to the BitBucket site, select your repo and you should see the code.

如果您想通过屏幕截图查看此信息的版本,请参阅我的

If you want to see a version of this information with screen shots, see my blog post.

这篇关于使用Xcode将现有项目添加到BitBucket的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆