38

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.

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

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

TheLearner
  • 19,387
  • 35
  • 95
  • 163

9 Answers9

26

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"

  4. "Source Control" -> "Commit"

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

  6. Click "Commit"

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

ArtOfWarfare
  • 20,617
  • 19
  • 137
  • 193
Ascendant
  • 2,430
  • 3
  • 26
  • 34
  • 2
    You and your answer are my new best friends. – ArtOfWarfare Apr 04 '15 at 19:52
  • I had to create the the git repo on bitbucket before xcode would push to it. ie: xcode couldn't create the remote repo for me. – jxmallett Jan 12 '17 at 22:59
  • Also, it seems xcode does an initial commit when it sets up the local repo, so you should be ok to just "push to remote" without doing a "commit" first. – jxmallett Jan 12 '17 at 23:00
22

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.

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):

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.

Tom
  • 508
  • 4
  • 16
15

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

  1. create a new repo on bitbucket
  2. assuming your xcode project is not under local git version control yet
  3. 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

    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
    
  4. go back to xcode and you should be able to interact with bitbucket through xcode from this point on

gzge
  • 179
  • 1
  • 3
14

Using the following URL structure

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

(Taken from here) did the job for me

Dan
  • 872
  • 10
  • 24
4

It is easier to:

  • create your local Git repo through XCode and add your code there
  • in command line, add the remote 'origin' toward your BitBucket repo, along with your ssh credentials (in ~/.ssh/config): see
  • do at least one "git push myrepo origin master" to initiate the first push
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
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

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.)

-Sign-up for BitBucket and create a repo

-In Xcode go to Source Control menu

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

-Select project and press Create in dialog window

-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

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

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

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

-Return to Source Control menu and select push

-Select the correct branch and Push

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

-Go to Source Control menu and select Pull.

Bobby
  • 6,115
  • 4
  • 35
  • 36
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

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.

CaptainBleuten
  • 95
  • 1
  • 1
  • 7
0

Most simplest way is go to

Xcode > preference > @accounts > click '+' button on corner left

... then this popup will appear ...

enter image description here

just click Bitbucket Cloud ...

enter image description here

Enter ID with password... And that's it...

Wahab Khan Jadon
  • 875
  • 13
  • 21