Getting started with Git/TFS
I recently moved one of my projects to a TFS Git repository. But Git did not start out as a Microsoft product, and Git is a relatively recent addition to TFS. The TFS Visual Studio tools give us some powerful shortcuts, but some things can only be done on the command line. Here’s how to get the best of both worlds.
Related: Using Git with Team Foundation Server and Visual Studio 2013
Install Git
If you haven’t done so, you’ll need to install Git. This will allow you to run the command line tools, and (as an added bonus) you’ll get a BASH shell as well. So if you ever wanted to have a Linux shell on your Windows box, now’s your chance. IMO it’s good to know Linux, but hey, I’m not here to lecture.
- Go to http://git-scm.com/download/win
- There are three options in the install. They can be a bit involved, but they’re worth reading carefully. If you’re avoiding the BASH shell, you’ll want to choose the option to make git available in the Widows path.
Set up alternate credentials in TFS
The first thing I found was that my Microsoft Online user name and password don’t work, when attempting to authenticate against git. A bit of research revealed that I had to take an additional step.
- Navigate to the git url for your git repository, and log in. In my case it was something like http://companyname.visualstudio.com/DefaultCollection/_git/rep-name/
- Click on your user name -> My profile -> Credentials. Click on the link at the bottom “Enable alternate credentials”, and create an alternate credential.
Clone your project
With Git, the way to get started with a project is to clone it. Among other things, this copies the entire repository to your working directory.
- Go back to the command line and issue the clone command:
git clone http://companyname.visualstudio.com/DefaultCollection/_git/rep-name/
- When prompted, use the alternate user name and password that you just set up.
The clone command will replicate the project on your local machine, and you’re good to go.
Most commands (including clone) can be performed directly in Dev Studio, but the command line will be there if you need it.
2 comments