Reputation: 31323
I need to keep my Xcode project in 2 remote repos. Below are the steps I took.
By Selecting Source Control -> Working Copies -> Configure -> Add Remote, I added two remotes.
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.
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://[email protected]/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/*
Upvotes: 2
Views: 3657
Reputation: 36317
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:
How I got myself into a detached head? Simply put I did something like git checkout c10847ae6708fadc73d451a68e2dsdf30dbbabd86
Upvotes: 4
Reputation: 31323
Okay, after some fiddling I was able to get it working. Again here are the steps I took.
First I committed my changes locally. I did this through Xcode.
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
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
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.
Upvotes: 3