in Appcelerator Titanium

One of the great things about remote source control (aside from saving your skin when you mess up some code or when a hard drive goes bad) is that it enables you to easily move or duplicate your development environment from one computer to another.  I like to be able to work on the big desktop in the office, then switch to the smaller laptop when I am traveling, or sitting outside, or at the kitchen table, or just anywhere that's not behind this desk otherwise I'm going to go nuts aaah!  But, I digress.

I noticed recently that on a single repository on my laptop I was being prompted for my github username and password in order to do pulls or pushes.  I thought maybe there was an issue with a keystore or global setting somewhere, but all my other github repos were working just fine, without the authentication prompts.

Cause

Turns out that when I cloned the repo on this computer, I had connected via the https url rather than the git url.  And, one of the features of the git url is that you don't have to mess with stuff like authentication (without making other changes).

Fix

There is a pretty easy solution for this.  All we need to do is switch our repo's url from the https:// version to the git:// version.  I haven't seen a way to do this via a Studio menu, but we can handle it through a git command, and we can even do that via Studio's terminal window (or another terminal window of your preference).

I am using github.com, and have created the examples using the github url. If you are using a different repo, or even your own local repo, just replace the url with your own.

1) First, let's verify that we are actually using the https url in our repo.  

From your repo directory, do:

git remote show origin

You will be prompted for a username and password (arrgh, again!) then you should see:

* remote origin Fetch URL:
https://github.com/username/repo
Push URL: https://github.com/username/repo ...

This verifies that we do have the https urls.

2) From the same terminal window and directory, do the following, replacing username/repo with those you saw in the command above.  Don't forget the .git at the end!

git remote set-url origin git@github.com:username/repo.git

If you need to verify the url, on github, go to your repo and click the SSH button next to the clone url.

3) Verify that the change worked by doing the same command from Step 1 — you shouldn't be prompted to login in order to do it, either!

Now you should be able to push, pull, etc. from Titanium Studio without those pesky login prompts.  For more info on switching your git url to SSH, go here.