Visual Studio Online + Git with XCode

Recently a friend of mine and myself decided to embark on a new project we are calling ‘OneList’.  After much deliberation we decided to use iOS for the initial release, it would be my first serious iOS application and I also decided to make it the first project where I use Git as it should be used, from the command line.

I like GitHub, but it really does lack the feature that Visual Studio Online has for Scrum.  The ability to use Git on Visual Studio Online and still get all the project management features of TFS is a huge plus, so we decided that would be the ideal place to store our code.  However, it also meant that I would have to connect XCode to Visual Studio Online through Git.  After doing some research I discovered two options for doing this: TFS Git and pure Git.

This is the same no matter what

No matter which approach you take you will need to ensure that a Git repository exists locally before you attempt to push to a remote repository.  Doing this in XCode is quite easy.  Make sure you have Git installed (here), this will also add it to your path.  When you create your project make sure to check the box indicating you wish to use Git for source control:




This will create your project and call git init on the directory, initializing the local git repository.  This works great as a starting point for a new project.  With an existing project, open a Terminal window, cd to the project root directory and run git init.

Here is where things get different

The path you pick here is going to depend on how you create your project using TFS online.  You would think that you would simply pick the Git variant and be done with it, not not so.

Approach 1: Its Git, but really its TFS

The Visual Studio Online site does not make this clear, but their recommended approach is to use Git with TFS.  See if you hit their instructions for using Git ( they recommend using this tool:  However, if you check their instructions carefully you will see that you are actually creating your project to use TFS and not Git.  This is essentially the “half Git” approach, cause you are only using Git locally, but TFS in the cloud.  Here are the steps:

  1. Use ‘New Team Project’ (the blue button) when you setup your project
  2. Make SURE to select ‘Team Foundation Version Control’ for Version Control (this is where I got messed up cause you would think to select Git)
  3. Look for your email address and access your Profile.  Look for the ‘Credentials” link
  4. Enable ‘Alternate Credentials’ and give yourself a custom username and password.  This is what we will use when accessing the server below
  5. Download git tf and make sure its appended to your $PATH.  If you are like me and already have Java you can ignore those instructions

Once you get it installed usage is quite easy.  Configure your project URL using git tf configure, here is an example of the one I used for OneListTest:

git tf configure –f $/OneListTest

Basically, give it the URL to your visual studio collection root and then tell it which team project to use.  This gets you configured.

As far as development goes, do things as normal using git locally to populate your local repository.  When you ready to push, you perform a checkin

git tf checkin

This will “push” your changes to the remote URL that you configured earlier.  Remember to provide your alternate credentials when prompted.  This approach is effectively “half Git” since you really arent using git all the way around.  The git tf wrapper is acting as a bridge between TFS and Git and performing the translation so if you are used to TFS you can use roughly the same terminology.

This works great if you have an existing TFS project in the cloud and want to use Git locally, but if your like me and want to fully leverage Git, you need to go a different route.

Approach 2: It really is Git

So given that the first approach used the “blue button” and was actually TFS on the server, you can guess where this approach will take us, yup the ‘Red Button’ or ‘New Team Project + Git’.  This time make sure that ‘Git’ is selected as the Version Control option (though it should default to this).

Ok, now that we have that setup, we need to configure our remote so we have somewhere to push to.  Without diving too much into Git and its terminology, remember that you keep a repository locally with your changes and then when you are ready you “push” to a remote/shared repository.  This is what is meant by “distributed source control”.  To add a remote you do something like the following:

git remote add

Remote name is the shortcut name of your remote repository, you will use this when you initiate a “push”.  The Url is the actually Git repository which will be committed against.  For example:

git remote add OneListTest

Confirm that your remote was added using git remote

Now you are set to go, work with your local repository like normal and when you are ready call git push to push your work to the remote/shared repository.

Side note, I do not recall entering my credentials when I did a push which felt weird to me.  Not sure if there is a security setting somewhere that I forgot or if I entered it somewhere else and it remembered.  Be careful of this, especially if you have secure source code.


In this article I walked through the basics of putting an XCode project, both existing and new under source control using Git.  I then described two approaches whereby these source control bases could be managed using Visual Studio Online, one using TFS under the hood and the other purely using Git.  I find Git quite fascinating and intriguing.  I choose to use Visual Studio Online over GitHub due to the greater number of features relating to Scrum based project management available through Visual Studio Online


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s