简体   繁体   English

如何使用BitBucket配置Xcode

[英]How to configure Xcode with BitBucket

I have created a repo. 我已经创建了一个仓库。 on bitbucket . bitbucket上 Now I want to connect that repo to the Xcode 9 .So I can directly push, pull and do all the git stuff from Xcode. 现在我想将该仓库连接到Xcode9 。因此,我可以直接从Xcode推入,拉出并执行所有git的工作。

is there any way to do that? 有什么办法吗?

thanks!!! 谢谢!!!

  1. If the project folder is already on your computer, and is already under git control, skip this first step. 如果项目文件夹已经在您的计算机上,并且已经在git的控制下,请跳过此第一步。 Otherwise, use the command line, or Xcode's Source Control > Clone dialog, to clone your bitbucket repo onto your computer. 否则,请使用命令行或Xcode的“源代码控制”>“克隆”对话框将您的位桶存储库克隆到计算机上。

  2. Open the project in Xcode and work with it. 在Xcode中打开项目并使用它。

  3. There is no step 3! 没有步骤3! Xcode will see that this repo is under git control and you'll be able to use Xcode's built-in source control features as usual. Xcode会看到此仓库在git的控制下,您将能够照常使用Xcode的内置源代码控制功能。

I just spent an hour cajoling Xcode 9.2 into using a new Bitbucket git repo as a new remote. 我只花了一个小时就让Xcode 9.2成为一个新的Bitbucket git repo作为新的遥控器。 I had trouble adding a new remote using the Bitbucket SSH URL since Xcode assumed my user name is "git" and did not allow me to edit it. 由于Xcode假定我的用户名为“ git”,并且不允许我对其进行编辑,因此使用Bitbucket SSH URL添加新的遥控器时遇到了麻烦。 Here are some tips in hopes it saves you some time and aggravation. 这里有一些技巧,希望它可以节省您的时间和麻烦。 This assumes you are already using Xcode's source control and have made commits locally on your Mac. 这假定您已经在使用Xcode的源代码控制,并且已经在Mac上本地进行了提交。 Make sure your commits are up to date before going through this procedure. 在执行此过程之前,请确保您的提交是最新的。

  1. Create a new empty git repo on Bitbucket. 在Bitbucket上创建一个新的空git repo。 Do not create a readme at this point, as this would make your new repo not... empty. 此时不要创建自述文件,因为这会使您的新存储库不为空。

  2. Use the HTTPS address to access your Bitbucket repo from Xcode. 使用HTTPS地址从Xcode访问您的Bitbucket存储库。 Problem is, for an empty repo, Bitbucket does not make it easy to figure out what this address is. 问题是,对于一个空的仓库,Bitbucket很难弄清楚这个地址是什么。 For me, it was the same URL Bitbucket shows for SSH access but replacing "git@bitbucket.org:" with " https://user@bitbucket.org/ ", with user@bitbucket.org (hopefully obviously) YOUR username. 对我来说,它是与Bitbucket显示的用于SSH访问的URL相同的URL,但是将“ git@bitbucket.org:”替换为“ https://user@bitbucket.org/ ”,并用user@bitbucket.org替换了您的用户名。

  3. In Xcode, open the Source Control Navigator. 在Xcode中,打开“源代码管理导航器”。 This is the second icon from the left in Xcode's left panel next to the folder icon, it looks like a square with an x and a circle in the middle. 这是Xcode左侧面板中文件夹图标旁边左侧第二个图标,它看起来像一个带有x和一个圆圈的正方形。 Right click "Remotes" and select "Add Existing Remote...". 右键单击“远程”,然后选择“添加现有的远程...”。 Under "Remote Name" enter "origin" or "Bitbucket" or whatever floats your boat and under location enter the https:// URL from step 2. 在“远程名称”下,输入“来源”或“ Bitbucket”,或在您的船上漂浮的任何东西,然后在位置下,输入步骤2中的https:// URL。

  4. Now, hooray, in Xcode you can do Source Control->Push successfully. 现在,hooray,在Xcode中,您可以成功执行Source Control-> Push。

Thank goodness Apple does all my thinking for me, it saves me from hurting my little brain. 谢天谢地,Apple为我竭尽全力,这使我免于受伤。 Now my only brain trauma is from banging my head against the wall dealing with this kind of nonsense. 现在,我唯一的脑部创伤来自于处理这种胡说八道的动作。

You can actually add real Github* account to your Xcode under Xcode/Preferences/Accounts. 您实际上可以在Xcode / Preferences / Accounts下将真实的Github *帐户添加到Xcode。

This will actually do authentication when you checkout Bitbucket project after that. 此后,当您签出Bitbucket项目时,这实际上将进行身份验证。 I guess that they joined user databases. 我想他们加入了用户数据库。

I had exactly the same problem as You had. 我遇到的问题与您完全一样。 To solve it I created a project with a git version control within Xcode 9 and then someone asked me to share it. 为了解决这个问题,我在Xcode 9中创建了一个带有git版本控件的项目,然后有人要求我共享它。 To do it I created an empty repo on bitbucket, copied its address and then went in terminal to my project's directory. 为此,我在bitbucket上创建了一个空的仓库,复制了它的地址,然后在终端中转到我项目的目录。

cd ~/repos/<repo_name>

Once there you just have to write 到达那里后,您只需要写

git push --mirror *copiedRepoAddress

Make sure that the repository you created at bitbucket is EMPTY and that you have commited all changes on your local repo. 确保您在bitbucket上创建的存储库为EMPTY,并且已在本地存储库中提交了所有更改。

Just follow below steps your project will be added automatically to bitbucket. 只需按照以下步骤,您的项目将自动添加到bitbucket。

1.Go to Source Controller ---> create git repository 1.转到Source Controller --->创建git仓库 在此处输入图片说明

once click on create option. 一旦点击创建选项。

2.Open your Bitbucket account and create new repository.And choose i have an existing project. 2.打开您的Bitbucket帐户并创建新的存储库。然后选择“我有一个现有项目”。 3.Select your repository address. 3.选择您的存储库地址。 在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

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

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