使用 Xcode 将现有项目添加到 BitBucket
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17690713/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Add existing project to BitBucket using Xcode
提问by Mark
I keep getting an error when I try to commit my project files using Xcode.
当我尝试使用 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."
“无法执行操作,因为找不到有效的工作副本。” “请验证您的文件是否受源代码控制,然后重试。”
This is an existing project that is NOT under source control. How do I get my project files under source control, using Xcode?
这是一个不受源代码控制的现有项目。如何使用 Xcode 在源代码控制下获取我的项目文件?
EDIT: Answered my own question.
编辑:回答了我自己的问题。
Step 1) Restart Xcode
步骤 1) 重新启动 Xcode
Step 2) Choose connect to repo
步骤 2) 选择连接到 repo
Step 3) Enter repo address
步骤 3) 输入回购地址
Step 4) Choose existing project folder you wish to place under version control
步骤 4) 选择要置于版本控制之下的现有项目文件夹
Step 5) Voila! :)
第 5 步)瞧!:)
回答by David Lari
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.)
由于很多人在谷歌“使用 Xcode 将现有项目添加到 BitBucket”时登陆这里,然后点击链接到我关于该主题的博客文章的链接,我想我会把信息放在这里(本着 SO 的精神)这不鼓励仅链接答案。)
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
注意:这些说明假设您已经为项目创建了本地 git 存储库。您可能在项目创建时已完成此操作。如果没有,您现在需要创建本地 git。有关如何执行此操作,请参阅此 StackOverflow 帖子:https: //stackoverflow.com/questions/19495141/add-local-repo-for-existing-xcode-5-project
For Xcode 9 and the new Beta UI for Bitbucket:
对于 Xcode 9 和 Bitbucket 的新 Beta UI:
- Log into your BitBucket Account on their web site.?
- Click the Create button (plus sign + in the newest version of the web UI). And click Repository.?
- 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.?
- 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://[email protected]/xyzteam/xyzapp.git. Highlight and copy that URL text.?
- Run Xcode and load your project.?
- 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…”?
- 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.?
- 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.
- 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 帐户。?
- 单击“创建”按钮(最新版本的 Web UI 中的加号 +)。然后单击存储库。?
- 为您的新存储库命名。可以在“高级”菜单下配置存储库的其他功能。如果您愿意,请确保选中“私人”的复选标记。验证存储库类型是否为 Git。如果需要,添加问题跟踪和 Wiki。从语言下拉列表中选择 Objective C 或 Swift。然后创建存储库。?
- 接下来,您将要添加代码。概览页面的顶部是一个字段,其中包含项目的 HTTPS URL。它看起来像这样:?https://[email protected]/xyzteam/xyzapp.git。突出显示并复制该 URL 文本。?
- 运行 Xcode 并加载您的项目。?
- 从 Xcode 的左窗格中,选择 Source Control Navigator。展开项目节点。右键单击项目下的 Remotes 节点。选择“添加现有遥控器...”?
- 给它一个远程名称,例如 Bitbucket。将步骤 4 中的 URL 粘贴到“位置”中。单击添加。它现在应该在源代码管理导航器中显示为远程位置。?
- 添加遥控器后,您现在应该可以推送到遥控器了。选择 Source Control/Push... 它应该显示你的 Bitbucket 遥控器作为目的地,并且会显示 (Create) 因为这是第一次推送。单击推送。
- 如果这是您第一次将此项目推送到 BitBucket,系统会要求您提供登录凭据。用户名将从 URL 中预先填充,因此请输入密码。单击“确定”,几秒钟后,它应该会完成。
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.
如果一切顺利,您现在已经链接了存储库。转到 BitBucket 站点,选择您的存储库,您应该会看到代码。
For Xcode older than version 9 and the old Bitbucket UI:
对于早于版本 9 的 Xcode 和旧的 Bitbucket UI:
Log into your BitBucket Account on their web site.
Click the Create button.
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.
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://[email protected]/xyzteam/xyzapp.git. Highlight and copy that URL text.
Run Xcode and load your project.
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.
Select the Remotes pane from this screen. At the bottom, click the plus +. Select Add Remote…
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.
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 帐户。
单击创建按钮。
为您的新存储库提供名称、描述,并确保选中 Private 的复选标记(如果您愿意)。验证存储库类型是否为 Git。如果需要,添加问题跟踪和 Wiki。从语言下拉列表中选择 Objective C 或 Swift。然后创建它。
接下来,您将要添加代码。我假设你有一个现有的项目。在页面上,您将从命令行部分选择“我有一个现有项目”链接。
您将看到将本地 git 存储库链接到远程的说明。无需遵循这些说明。但是,您将看到列出的 https 网址。它看起来像这样:https://[email protected]/xyzteam/xyzapp.git。突出显示并复制该 URL 文本。
运行 Xcode 并加载您的项目。
从主菜单中,选择源代码管理。在灰色的“工作副本”项下,您将看到一个菜单,其中包含您的本地 git 存储库名称和当前活动的分支。展开此菜单,您将看到一个用于配置 [您的项目]...的选项。选择这个。
从此屏幕中选择远程窗格。在底部,单击加号 +。选择添加远程...
现在您需要一个名称和一个 URL。对于名称,通常只使用您的项目名称,然后粘贴前面在步骤 5 中复制的 URL。有些人发现他们必须删除 URL 的用户名部分。根据示例,删除“johndoe@”。这可能与您的项目是设置为团队项目还是个人项目有关。
单击添加远程。单击完成。
添加遥控器后,您现在应该可以推送到遥控器了。选择源控制/推送...。如果这是您第一次将此项目推送到 BitBucket,您可能会被问及钥匙串访问和/或登录凭据。输入适当的响应,例如 Allow for keychain。如果您之前已经这样做过,它只会使用钥匙串数据而无需进一步提示。
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.
如果一切顺利,您现在已经链接了存储库。转到 BitBucket 站点,选择您的存储库,您应该会看到代码。
If you want to see a version of this information with screen shots, see my blog post.
如果您想通过屏幕截图查看此信息的版本,请参阅我的博客文章。
回答by Abhishek Mishra
Login your bit bucket account
and Create a repository
in your account
登录您的位bucket account
并repository
在您的帐户中创建一个
open terminal
run these following command
打开terminal
运行以下这些command
1- cd /path/to/your/repo
1- cd /path/to/your/repo
2- git remote add origin <url of your repository >
2- git remote add origin <url of your repository >
3- git push -f origin master
3- git push -f origin master
it works for me, Thanks.
它对我有用,谢谢。