2

I need to keep my Xcode project in 2 remote repos. Below are the steps I took.

  1. Created an empty folder in my Mac.
  2. Added a .gitignore file.
  3. Created a project using Xcode 6.2.
  4. Created a repo on Bitbucket.
  5. Created a repo on Github.
  6. By Selecting Source Control -> Working Copies -> Configure -> Add Remote, I added two remotes. enter image description here

  7. Then by selecting Xcode Preferences -> Accounts, I filled up the user credentials for each account.

Then I went to commit the initial changes of my project by selecting Source Control -> Commit, it keeps showing Loading remotes... in the remote selection drop down but it wouldn't load.

enter image description here

Am I missing something here? Any steps I missed? I also tried adding them individually to see if it's something with one of the remotes but that didn't work for both of them either.

I opened the git config file on TextEdit and this is what I have there.

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
[remote "bitbucket"]
    url = https://Isuru-Nanayakkara@bitbucket.org/Isuru-Nanayakkara/coolproject.git
    fetch = +refs/heads/*:refs/remotes/bitbucket/*
[remote "github"]
    url = https://github.com/Isuru-Nanayakkara/CoolProject.git
    fetch = +refs/heads/*:refs/remotes/github/*
Isuru
  • 30,617
  • 60
  • 187
  • 303
  • You could try and declare both remote under one name, to see if that works better: http://stackoverflow.com/a/18637593/6309. – VonC Mar 13 '15 at 19:40
  • @VonC Hi, thanks for the response. I tried it but that didn't work either. Although I was able to resolve my issue in a different way. I posted it as an [answer](http://stackoverflow.com/a/29041553/1077789). – Isuru Mar 13 '15 at 20:40

2 Answers2

4

I was on a detached head (a commit made by another developer) hence there was no matching commit on my branches from my repo. As a result I was getting this:

enter image description here

How I got myself into a detached head? Simply put I did something like git checkout c10847ae6708fadc73d451a68e2dsdf30dbbabd86

Community
  • 1
  • 1
mfaani
  • 33,269
  • 19
  • 164
  • 293
3

Okay, after some fiddling I was able to get it working. Again here are the steps I took.

  1. First I committed my changes locally. I did this through Xcode.

  2. Since the remotes weren't showing in Xcode, I turned to the Terminal's aid. First I pushed to Bitbucket's repo. Initially I tried with git push bitbucket but that would give me an error. Upon searching I found out that I need to set a default remote for my local repo. So I ran the following command and the changes were pushed to the Bitbucket's repo successfully.

    git push --set-upstream bitbucket master

  3. Then when I tried to push to the github with git push github, I got this new error ![rejected] master -> master (fetch first). Even after pulling the latest from Bitbucket, I'd still get this error. So in the end to get past this, I ran the following command and force pushed the repo to Github as well.

    git push -f github master

  4. After that now I can do my changes in Xcode and push to both remotes from Xcode itself. Now the remotes appear in the drop down! Maybe this is an Xcode bug(?).

Note: If the steps I took are wrong or if there is a cleaner or more right way to go about this, please post your answer. I'm still very much open for suggestions.

Isuru
  • 30,617
  • 60
  • 187
  • 303
  • That would explain the "loading" issue: the GitHub repo wasn't compatible (because it had already an history of its own and wasn't really empty). – VonC Mar 13 '15 at 20:50