Associate Work Items to check-in in a TF Service Git enabled repository

Even if we are still in preview, Git support in TF Service already has some nice integration between git and all the rest of the world of TFS. As an example suppose you have a Work Item you are working to.


Figure 1: Simple Work Item in web interface

Now suppose you want to associate a local commit to this Work Item, all you need to do is inserting hashtag followed by the id of the Work Item in the comment of the commit, es #437. Since we are in the first preview of Git support actually there is no UI support, but using a simple comment is really quick and simple.


Figure 2: A commit that contains a reference to a Work Item

Now when you push changes to the TF Service, the commit will be associated to the corresponding Work Item, as you can see from Web Interface Code browser.


Figure 3: The Commits explorer window shows associated Work Item and all other details of the commit

As you can verify from Figure 3, you are able to visualize all the details of the commit with related Work Items included. You can click the link to the Work Item and you are bring to the Work Item editor where you can verify that the association is correctly done directly to the Work Item.


Figure 4: Commit is correctly associated with a Commit Link to the related Work Item

The association is not only in the commit explorer, but a real link is created between the Work Item artifact and the commit in code, as it happens in standard TFS VCS where the link points to a changesetid.

Gian Maria.

Move a TFService source control to TF Service Git based Team Project

Now that with Update 2 we have Git support on TF Service a standard question arise: “how can I move all source from a TF Service standard project to a TF Service Git based Team Project?” The answer is quite simple

First of all you need to install and Configure Git-Tf, an addin that permits to clone a TFS source control in a local Git repository, this is needed to have a full local clone of the source project you want to migrate. Then you need to create a new Team Project in TFService that is based on a Git repository.


Figure 1: Create a new team project with Git as a Version Control System.

Now you need to create a local clone of the original Team Project thanks to tf-git, just open a Git Bash console in a folder of your choice and type the command

git-tf clone –deep $/webfacade

Pay attention to use the –deep option to clone all check-ins of the original TFS repository, you now will be prompted for credentials and the clone operation will begin. I strongly suggest you to Enable Alternate Credentials to connect to your TFS so you can use a standard username/password combination to connect to your TFS Account. Now you can move into the new folder that will have the same name of your TFS Project and you should see all your original check-ins cloned in a local git repository.


Figure 2: after a git-tf clone –deep you now have a local git repository with all original check-ins

Now you can work locally with git and use a standard TFS Version Control System thanks to the git-tf, but since now TF Service has support for standard Git enabled Team Projects, you can push all commits to the new Team Project just created in Figure 1 and start working with Git.

To accomplish this you can simply set the remote for this repository to be able to push and pull changes from your new TeamProject running the following three commands.

git remote add origin
git fetch
git push origin master:master

The url of the git repository is the standard url for your TF Service project collection followed by the /_git/teamprojectname part that identifies the git repository. The git fetch command will be prompt for password and is used to contact the remote repository and fetch modifications. In our situation we do not have any modification since the repository is empty so nothing happens except you contact the remote server and verify if the remote was set correctly. Finally push command will force the local master branch to be pushed to the remote master branch (and it implicitly creates remote master branch if it does not exists because the repository is empty).


Figure 3: Push command creates the remote master branch and pushed all local changes to TF Service Git repository

The result is the creation of a new branch in the remote TF Service git enabled project, and you should now be able to see all the commits from the web interface.


Figure 4: As result of the push, all original check-in into the original project are now standard git commit in the new repository

Now you need a final git command to setup the remote branch as the default upstream of your local master branch

git branch –set-upstream master origin/master

This command will setup the default connection with your new TF Service Git enabled project, now you can start to work normally with Git. As an example I added a readme.txt, committed locally and finally issued a simple “git push” and, voilà, you have done the first push of modification to Git repository in TF Service.


Figure 5: The git push operation pushed modification to the upstream TF Service Git server

To read how to work with Git and the new CTP Visual Studio plugin I suggest you reading this post.

Gian Maria.