How do I configure Git in Xcode to work with BitBu

2020-02-16 07:16发布

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

8条回答
该账号已被封号
2楼-- · 2020-02-16 07:17

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

查看更多
看我几分像从前
3楼-- · 2020-02-16 07:18

Using the following URL structure

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

(Taken from here) did the job for me

查看更多
Bombasti
4楼-- · 2020-02-16 07:21

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
查看更多
ら.Afraid
5楼-- · 2020-02-16 07:24

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

查看更多
霸刀☆藐视天下
6楼-- · 2020-02-16 07:33

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

查看更多
ゆ 、 Hurt°
7楼-- · 2020-02-16 07:36

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.

查看更多
登录 后发表回答