Today I’m starting a new series of blog posts entitled “Code Mill Minute”. These will be a departure from my normal novel length posts (I’m trying to shorten those too, but that’s another story) and will focus on just fixing or doing something that we developers encounter on a day to day basis.

Short and sweet… to the point… and only takes a minute to read.

So let’s dive into today’s topic … integrating Xamarin Studio on the Mac with TFS Online’s (aka Visual Studio Online) Git source control.

The Problem

By default, the account you login as to Visual Studio Online is your Microsoft account, which is an email address. The problem with that is the [email protected] symbol. Applications other than Visual Studio have an issue using that symbol to connect with Git.

The Solution

We need to enable another set of credentials in TFS Online, link the new credentials up to our existing VSOnline account, clone the repository with our new user, then have Xamarin Studio perform a remote Git operation, so it can cache the user credentials as well.

Enabling VSOnline Alternate Credentials

The first thing we’ll do is enable alternate credentials in VSOnline. To do so, follow these steps.

  1. Login to VSOnline with your normal credentials
  2. In the upper right corner, you’ll see your name, click on that, then click on “My Profile” in the resulting dropdown.
  3. A screen similar to the one below will appear. Click on the “Credentials” tab and then “Enable Alternate Credentials”.
    Enabling Alternate Credentials
  4. Enter the username and password you want to use for Git access with Xamarin Studio (or the command line).

Integrating With Xamarin Studio on the Mac

Next we need to clone the repository with the new credentials, then make sure Xamarin Studio has those credentials cached as well.

  1. First, note the clone URL of the repository from TFS Online. (This can be found from the “clone” button while viewing the top level source code structure within TFS Online website.)
  2. Open up Terminal and navigate to the directory you want to clone the repository to.
  3. Run the Git clone command with the URL of the repository you want to clone to (from step 1 above).
    git clone “https://testproject.visualstudio.com/DefaultCollection/_git/Test”
  4. You’ll be prompted for your username and password – enter the “alternate” ones you just created.
  5. Then you’ll see a screen similar to this… I had no idea what it was at first & I thought I did something wrong, but then I realized it was the friendly Visual Studio logo!
    TFS Git Cloning!
  6. Finally, you can start using local Git within Xamarin Studio as normal. When you need to do the first operation against the remote repository, you’ll be prompted for your username and password – again this is the “alternate credentials” you created. Once entered, Xamarin Studio will cache them, and you’ll be off and running!

That’s all there is to getting a TFS Online Git repository working with Xamarin Studio on the Mac … the secret sauce really is just enabling alternate credentials with your Visual Studio Online account. Once that’s done… off to the races!