如何在Xcode中将Git配置为使用BitBucket

时间:2021-12-08 07:23:42

I have a project which I have been on for ages which is not connected to any source code repository.

我有一个项目,我已经从事了很长时间,它没有连接到任何源代码存储库。

I want to start using BitBucket now, however I am not sure how to go about it. I have created a project in BitBucket.

我现在想开始使用BitBucket,但是我不知道该怎么做。我在BitBucket中创建了一个项目。

Should I now clone and check out in Xcode or should I add a repository in xcode. Anyone have any idea?

我现在应该在Xcode中克隆并签出它,还是应该在Xcode中添加存储库。有人知道吗?

I have tried cloning using the URL from bitbucket but it just comes back with an error in Xcode

我尝试过使用bitbucket的URL进行克隆,但是它返回时出现了Xcode中的错误

8 个解决方案

#1


4  

As of 2017, xCode now automatically creates repositories for new projects. To push to a new BitBucket repo, go to 'Source Control' > 'Commit...' in xCode and make your first local commit.

到2017年,xCode将自动为新项目创建存储库。要推送一个新的BitBucket repo,请访问“源代码控制”>“提交…”在xCode中,第一个本地提交。

Next open a terminal and navigate to to the top-level directory of your project. If you ls -a in here you should see the .git/ directory has been created. In the same directory, add your remote repo with the following (replace with your username/team name and repo name):

接下来打开一个终端,导航到项目的*目录。如果ls -a在这里,您应该看到.git/目录已经创建。在相同的目录中,添加以下远程repo(用您的用户名/团队名和repo名替换):

git remote add origin https://USERNAME@bitbucket.org/USERNAME/REPO_NAME.git

Go back into xCode, go to 'Source Control' > 'Push...'. You'll be prompted to enter your BitBucket password. Press OK and you're done! Source control commands will now be working within xCode.

回到xCode,转到“源代码控制”>“Push…”。您将被提示输入您的位桶密码。按OK,你就完成了!源代码控制命令现在将在xCode中工作。

#2


24  

I've met the same problem and here's how I solved it:

我遇到过同样的问题,我是这样解决的:

  1. (Assume your project is not already under local source control) Create a new project under LOCAL source control (Please note that adding remote source control at this stage may not be successful)

    (假设您的项目尚未在本地源代码控制下)在本地源代码控制下创建一个新项目(请注意,在此阶段添加远程源代码控制可能不会成功)

  2. Make this new project a clone of your old project - drag files, add frameworks, etc.

    使这个新项目成为旧项目的克隆——拖放文件、添加框架等。

  3. In menu "Source Control" -> -> "Configure " In the new window, click on "Remotes" -> "+" -> "Add Remote"

    在菜单“源控制”-> ->“配置”在新窗口,点击“Remotes”->“+”->“添加远程”

  4. "Source Control" -> "Commit"

    “源头控制”- >“提交”

  5. Select "push to remote" at the left bottom corner

    在左下角选择“push to remote”

  6. Click "Commit"

    点击“提交”

  7. Check on BitBucket website to see if it's actually pushed to it

    查看BitBucket网站,看看它是否真的被推到了

#3


13  

Using the following URL structure

使用以下URL结构

https://accountname@bitbucket.org/accountname/reponame.git

(Taken from here) did the job for me

(从这里拿走)为我做了那份工作

#4


13  

I did that through command line and it is fairly straightforward.

我是通过命令行完成的,非常简单。

  1. create a new repo on bitbucket
  2. 在bitbucket上创建一个新的repo
  3. assuming your xcode project is not under local git version control yet
  4. 假设您的xcode项目还不在本地git版本控制之下
  5. go to command line, cd to your xcode project directory, and the follow the bitbucket doc: https://confluence.atlassian.com/display/BITBUCKET/Import+code+from+an+existing+project

    转到命令行,cd到您的xcode项目目录,并遵循bitbucket文档:https://confluence.atlassian.com/display/BITBUCKET/Import+代码+from+ + +现有+项目。

    git init
    git remote add origin git@bitbucket.org:<user_id>/<repo>.git
    git add .
    git commit -am 'init commit'
    git push -u origin master
    
  6. go back to xcode and you should be able to interact with bitbucket through xcode from this point on

    回到xcode中,你应该能够通过xcode与bitbucket进行交互。

#5


4  

It is easier to:

更容易:

  • create your local Git repo through XCode and add your code there
  • 通过XCode创建本地Git repo并在其中添加代码
  • in command line, add the remote 'origin' toward your BitBucket repo, along with your ssh credentials (in ~/.ssh/config): see
  • 在命令行中,向BitBucket repo添加远程“起源”,以及ssh凭据(在~/.ssh/config中):参见“BitBucket + XCode 4.2 + Git”。“使用带位桶的SSH协议”
  • do at least one "git push myrepo origin master" to initiate the first push
  • 至少做一个“git推myrepo源主进程”来启动第一个推

#6


1  

This link helped me, I will also copy and paste the instructions in case the link goes away.

这个链接帮助我,我也将复制和粘贴说明,以防链接消失。

http://sketchytech.blogspot.com/2016/02/send-xcode-project-to-bitbucket.html

http://sketchytech.blogspot.com/2016/02/send-xcode-project-to-bitbucket.html

Sending a non-git Xcode Project to BitBucket from GitHub is the most popular place to host your repos but if you are looking for a free service for teams that are 5 members or less then take a look at BitBucket. Here are instructions for moving a local Xcode project onto BitBucket. (Note: if you opted for a local Git when you created your project you should be able to skip steps 3 and 4.)

从GitHub向BitBucket发送一个非git Xcode项目是最受欢迎的地方,但如果您正在为5个成员或更少的团队寻找免费服务,那么请查看BitBucket。下面是将本地Xcode项目移动到BitBucket上的说明。(注意:如果您在创建项目时选择了本地Git,那么您应该可以跳过步骤3和步骤4。)

-Sign-up for BitBucket and create a repo

-为BitBucket注册并创建一个repo

-In Xcode go to Source Control menu

- Xcode进入源代码控制菜单

-Select "Create a working copy ...."

选择“创建一个工作副本....”

-Select project and press Create in dialog window

-在对话框窗口中选择项目并按下Create

-Return to Source Control menu and select -> Configure ...

-返回源代码控制菜单,选择->配置…

-Click "Remotes" tab

点击“遥控器”选项卡

-Press add "+"

新闻添加“+”

-Copy and paste the https address you see at the top right of your repo page into the remote location in Xcode

-复制并粘贴您在repo页面右上角看到的https地址到Xcode中的远程位置

-Go to Source Control menu and select Push... to upload the project

-进入源代码控制菜单,选择Push…上传项目

Pushing code updates to BitBucket Now you have it set up whenever you want to push code to the project:

将代码更新推到位桶中,现在可以随时将代码推到项目中:

-Go to Source Control menu and select Commit

-进入源控制菜单并选择Commit。

-Write a commit note and uncheck anything not to be included in the commit

-写一个提交说明,不检查提交中不包含的任何内容

-Return to Source Control menu and select push

-返回源代码控制菜单,选择push

-Select the correct branch and Push

-选择正确的分支并按下

Pulling code down from BitBucket repo To get code provided by others down from BitBucket:

从BitBucket repo中提取代码,从BitBucket中获取其他人提供的代码:

-Go to Source Control menu and select Pull.

-转到“源代码控制”菜单,选择“拉”。

#7


0  

I use SourceTree and Xcode 6.1 and in my case I first create a repository on bitbucket, then I clone my repository on an empty folder (using SourceTree or via command line) then when you create the new project on XCode in that folder, you can commit push and pull normally from XCode

我使用SourceTree Xcode 6.1和在我的例子中我第一次bitbucket都创建一个存储库,然后我克隆存储库在一个空的文件夹(使用SourceTree或通过命令行),那么当你创建文件夹的Xcode的新项目,你可以从Xcode提交推和拉一般

#8


0  

I found this youtube video and it helped me a lot, used this Atlasssian help for ssh authentication, and encountered an Xcode problem for which the solution can be found in this page.

我找到了这个youtube视频,它帮了我很大的忙,使用这个Atlasssian帮助ssh身份验证,并且遇到了一个Xcode问题,在这个页面中可以找到解决方案。

#1


4  

As of 2017, xCode now automatically creates repositories for new projects. To push to a new BitBucket repo, go to 'Source Control' > 'Commit...' in xCode and make your first local commit.

到2017年,xCode将自动为新项目创建存储库。要推送一个新的BitBucket repo,请访问“源代码控制”>“提交…”在xCode中,第一个本地提交。

Next open a terminal and navigate to to the top-level directory of your project. If you ls -a in here you should see the .git/ directory has been created. In the same directory, add your remote repo with the following (replace with your username/team name and repo name):

接下来打开一个终端,导航到项目的*目录。如果ls -a在这里,您应该看到.git/目录已经创建。在相同的目录中,添加以下远程repo(用您的用户名/团队名和repo名替换):

git remote add origin https://USERNAME@bitbucket.org/USERNAME/REPO_NAME.git

Go back into xCode, go to 'Source Control' > 'Push...'. You'll be prompted to enter your BitBucket password. Press OK and you're done! Source control commands will now be working within xCode.

回到xCode,转到“源代码控制”>“Push…”。您将被提示输入您的位桶密码。按OK,你就完成了!源代码控制命令现在将在xCode中工作。

#2


24  

I've met the same problem and here's how I solved it:

我遇到过同样的问题,我是这样解决的:

  1. (Assume your project is not already under local source control) Create a new project under LOCAL source control (Please note that adding remote source control at this stage may not be successful)

    (假设您的项目尚未在本地源代码控制下)在本地源代码控制下创建一个新项目(请注意,在此阶段添加远程源代码控制可能不会成功)

  2. Make this new project a clone of your old project - drag files, add frameworks, etc.

    使这个新项目成为旧项目的克隆——拖放文件、添加框架等。

  3. In menu "Source Control" -> -> "Configure " In the new window, click on "Remotes" -> "+" -> "Add Remote"

    在菜单“源控制”-> ->“配置”在新窗口,点击“Remotes”->“+”->“添加远程”

  4. "Source Control" -> "Commit"

    “源头控制”- >“提交”

  5. Select "push to remote" at the left bottom corner

    在左下角选择“push to remote”

  6. Click "Commit"

    点击“提交”

  7. Check on BitBucket website to see if it's actually pushed to it

    查看BitBucket网站,看看它是否真的被推到了

#3


13  

Using the following URL structure

使用以下URL结构

https://accountname@bitbucket.org/accountname/reponame.git

(Taken from here) did the job for me

(从这里拿走)为我做了那份工作

#4


13  

I did that through command line and it is fairly straightforward.

我是通过命令行完成的,非常简单。

  1. create a new repo on bitbucket
  2. 在bitbucket上创建一个新的repo
  3. assuming your xcode project is not under local git version control yet
  4. 假设您的xcode项目还不在本地git版本控制之下
  5. go to command line, cd to your xcode project directory, and the follow the bitbucket doc: https://confluence.atlassian.com/display/BITBUCKET/Import+code+from+an+existing+project

    转到命令行,cd到您的xcode项目目录,并遵循bitbucket文档:https://confluence.atlassian.com/display/BITBUCKET/Import+代码+from+ + +现有+项目。

    git init
    git remote add origin git@bitbucket.org:<user_id>/<repo>.git
    git add .
    git commit -am 'init commit'
    git push -u origin master
    
  6. go back to xcode and you should be able to interact with bitbucket through xcode from this point on

    回到xcode中,你应该能够通过xcode与bitbucket进行交互。

#5


4  

It is easier to:

更容易:

  • create your local Git repo through XCode and add your code there
  • 通过XCode创建本地Git repo并在其中添加代码
  • in command line, add the remote 'origin' toward your BitBucket repo, along with your ssh credentials (in ~/.ssh/config): see
  • 在命令行中,向BitBucket repo添加远程“起源”,以及ssh凭据(在~/.ssh/config中):参见“BitBucket + XCode 4.2 + Git”。“使用带位桶的SSH协议”
  • do at least one "git push myrepo origin master" to initiate the first push
  • 至少做一个“git推myrepo源主进程”来启动第一个推

#6


1  

This link helped me, I will also copy and paste the instructions in case the link goes away.

这个链接帮助我,我也将复制和粘贴说明,以防链接消失。

http://sketchytech.blogspot.com/2016/02/send-xcode-project-to-bitbucket.html

http://sketchytech.blogspot.com/2016/02/send-xcode-project-to-bitbucket.html

Sending a non-git Xcode Project to BitBucket from GitHub is the most popular place to host your repos but if you are looking for a free service for teams that are 5 members or less then take a look at BitBucket. Here are instructions for moving a local Xcode project onto BitBucket. (Note: if you opted for a local Git when you created your project you should be able to skip steps 3 and 4.)

从GitHub向BitBucket发送一个非git Xcode项目是最受欢迎的地方,但如果您正在为5个成员或更少的团队寻找免费服务,那么请查看BitBucket。下面是将本地Xcode项目移动到BitBucket上的说明。(注意:如果您在创建项目时选择了本地Git,那么您应该可以跳过步骤3和步骤4。)

-Sign-up for BitBucket and create a repo

-为BitBucket注册并创建一个repo

-In Xcode go to Source Control menu

- Xcode进入源代码控制菜单

-Select "Create a working copy ...."

选择“创建一个工作副本....”

-Select project and press Create in dialog window

-在对话框窗口中选择项目并按下Create

-Return to Source Control menu and select -> Configure ...

-返回源代码控制菜单,选择->配置…

-Click "Remotes" tab

点击“遥控器”选项卡

-Press add "+"

新闻添加“+”

-Copy and paste the https address you see at the top right of your repo page into the remote location in Xcode

-复制并粘贴您在repo页面右上角看到的https地址到Xcode中的远程位置

-Go to Source Control menu and select Push... to upload the project

-进入源代码控制菜单,选择Push…上传项目

Pushing code updates to BitBucket Now you have it set up whenever you want to push code to the project:

将代码更新推到位桶中,现在可以随时将代码推到项目中:

-Go to Source Control menu and select Commit

-进入源控制菜单并选择Commit。

-Write a commit note and uncheck anything not to be included in the commit

-写一个提交说明,不检查提交中不包含的任何内容

-Return to Source Control menu and select push

-返回源代码控制菜单,选择push

-Select the correct branch and Push

-选择正确的分支并按下

Pulling code down from BitBucket repo To get code provided by others down from BitBucket:

从BitBucket repo中提取代码,从BitBucket中获取其他人提供的代码:

-Go to Source Control menu and select Pull.

-转到“源代码控制”菜单,选择“拉”。

#7


0  

I use SourceTree and Xcode 6.1 and in my case I first create a repository on bitbucket, then I clone my repository on an empty folder (using SourceTree or via command line) then when you create the new project on XCode in that folder, you can commit push and pull normally from XCode

我使用SourceTree Xcode 6.1和在我的例子中我第一次bitbucket都创建一个存储库,然后我克隆存储库在一个空的文件夹(使用SourceTree或通过命令行),那么当你创建文件夹的Xcode的新项目,你可以从Xcode提交推和拉一般

#8


0  

I found this youtube video and it helped me a lot, used this Atlasssian help for ssh authentication, and encountered an Xcode problem for which the solution can be found in this page.

我找到了这个youtube视频,它帮了我很大的忙,使用这个Atlasssian帮助ssh身份验证,并且遇到了一个Xcode问题,在这个页面中可以找到解决方案。