Microsoft Team Foundation Server 2015 Cookbook
上QQ阅读APP看书,第一时间看更新

Creating a Git repository in an existing TFVC Team Project

Traditionally, it has only been possible to have TFVC as a source control repository. TFS started supporting Git as a source control from TFS 2013 onwards. Git offers many benefits for distributed Teams collaborating across the same codebase; you can read more about the benefits here at https://git-scm.com/about. TFVC Teams that are keen to try out Git, but cannot because of the rework involved in migrating their existing investments now have a solution. TFS now supports hybrid Team Projects. In this recipe, you'll learn how to set up a Git repository within an existing TFVC-based Team Project.

Getting ready

In Team Foundation Server 2015 Update 1, you need to be a member of the project administrator group to make an existing TFVC or Git project into a hybrid project, a project that hosts both a TFVC repository and multiple Git repositories. Users will need Visual Studio 2015 Update 1 to work with the hybrid project. Older versions of Visual Studio, including 2015 RTM, will see the project as the type it was originally created as.

If your TFVC project was created prior to TFS 2015 Update 1, a project administrator will need to apply some project-level permissions once the first repository has been created. Go to the version control administration page and select the Git repositories node in the tree. To set up the same group permissions as any of the default process templates (Agile, Scrum, and CMMI), add the following TFS groups and grant the following permissions:

  • [ProjectName]\Readers
    • - Allow: Read
    • - Not set: All others
  • [ProjectName]\Contributors
    • - Allow: Branch creation, Contribute, Note management, Read, and Tag creation
    • - Not set: All others
  • [ProjectName]\Build Administrators
    • - Allow: Branch creation, Contribute, Note management, Read, and Tag creation
    • - Not set: All others

Similarly, when creating a TFVC repository with in a Git Team Project that was created before TFS 2015 Update 1, the following folder level permissions need to be amended.

Go to the version control administration page and select the $/_ProjectName_ node in the tree. To set up the same groups as any of the default process templates (Agile, Scrum, and CMMI), add the following TFS groups and grant the following permissions:

  • [ProjectName]\Readers
    • - Allow: Read
    • - Not set: All others
  • [ProjectName]\Contributors
    • - Allow: Check in, Check out, Label, Lock, Merge, and Read
    • - Not set: All others
  • [ProjectName]\Build Administrators
    • - Allow: Check in, Check out, Label, Lock, Merge, and Read
    • - Not set: All others

If your Team Project was created after TFS 2015 Update 1, these permissions will have already been applied for you, and no action is necessary except creating the repository.

How to do it...

  1. Navigate to the code hub in FabrikamTFVC Web Portal by browsing to http://TFS2015:8080/DefaultCollection/FabrikamTFVC/_versionControl.
  2. As illustrated in the following screenshot, click on FabrikamTFVC to pull down the Options menu. To create a new Git repository, click on New repository... from the Options menu. Name the repository FabrikamFeature1 and click on Create:

    Note

    Note that there is no support for creating multiple TFVC repositories within the same Team Project. There is support for creating multiple Git repositories.

  3. The create operation will redirect you to a Git getting started page. The getting started page allows you to generate a clone of the repository and command-line credentials, create a README file to describe your repository and provide commands to set up the Git repository to work with Xcode, Eclipse, and Visual Studio. Click on Clone in Visual Studio to start working on the new repository in Visual Studio:
  4. As a result of this action, the repository is cloned in Visual Studio:

How it works...

Many customers are actively using TFVC repositories and have a rich Work Item history and customization in their Team Project. To make it easy for these Teams to start using Git, the Team Project model in TFS has been modified to support multiple source control repositories. Hybrid projects allow creating as many Git repositories as you need in your TFVC project. This model now also supports creating a TFVC repository in a Git project.

Team Explorer has been enhanced in TFS Update 1 to provide support for operating the hybrid Team Project. As illustrated in the following image, the manage connections page in Team Explorer lists all source control repositories in the Team Project. The workflows in Team Explorer are adjusted based on the repository type you are connected to.

The Web Portal also allows context switching between the TFVC and Git source control in the code hub. The workflows associated to the source control are made available based on the selection. For example, on selecting Git, you can see the option for Pull requests, while in the context of TFVC, you see the option for shelvesets.

There's more...

A recent roadmap of investments in Git experiences for Team Foundation Server and Visual Studio Online talks about support for Pull requests within Team Explorer and support for Git Large File Storage and GitFlow; you can read more about this at http://bit.ly/1RXQRS1.