Monday, October 14, 2013

Free private Git repository on TFS

You know GitHub of course, but it's not free for private repositories. Another nice option is BitBucket by Atlassian, which supports Git and Mercurial.

In this quick post I'm going to show you an option you may like especially if you're doing work in Visual Studio (like .NET/C#).  Not many people seem to know that Microsoft has a free Git hosting option called Team Foundation Service. This is basically a free online/hosted version of the TFS that we all know and love. (A bit of sarcasm there. Maybe.) The online TFS supports up to 5 users in your project for free.

Go to tfs.visualstudio.com, log in with your "Live ID" (like Hotmail/MSN/Outlook email address), and choose your own subdomain under .visualstudio.com. Create your new Git repository, 'test' in the example below.

When you're just starting with your new repository, initialize the new repo:
git init
Let's create our first file in the new repo:
echo '# Welcome!' > README.md
Now see what's going on in our repo:
git status
This shows us that we have the new README.md file as an "untracked file". Let's add the new file:
git add .
If you want, do a git status again, and note that the file is now added and new. 
Next, commit the change:
git commit -m "Initial commit"
Add the remote server called 'origin':
git remote add origin https://myname.visualstudio.com/DefaultCollection/_git/test
Now upload your newly created repository:
git push -u origin --all
(Note that your username and email address defined in your global git config is what will be displayed when you commit changes to this Git repo. This may perhaps be different from your TFS login, which is not necessarily what you want. So just make sure to check your config if you're using multiple Git accounts.)

Now add your friends to your private repo, and then they can clone the repository:
git clone https://myname.visualstudio.com/DefaultCollection/_git/test
Also see:

* SourceTree (Very good GUI for Git by Atlassian)
* GitHub for Windows client (also useful to get the PoshGit shell which is nice for command-line work)
* To create a new Git repository from Visual Studio, see: Publish your code into Team Foundation Service

Post a Comment