Search code examples
gittfstfvctf-cli

How to store and switch between code versions easily with TFVC


I am using local workspace. Now, say I am working on two different features, each with file modifications, file additions, and file deletions.

What is the easiest way to maintain the state and switch between two versions of code for these two features?

In git, I would simply create a branch for each, and then checkout either one at any time.

How can I accomplish this in TFVC, and be sure all changes are reverted from current version of code correctly (i.e. all file modifications are undone, all added files are removed, and all deleted files are restored), and be sure that all changes are applied correctly from the version of code I am switching to?


Solution

  • There is no comparable "switch in place" option in TFVC. It's just not how TFVC works. You map one or more folders to disk, some of which just happen to be branches. If TFVC you'd have a few options that can help you though:

    Workspace

    Create a new workspace and get the changes for the specific feature you're working on. That makes sure that both development efforts are truly isolated on the same machine.

    You'd open the Solution/Project from the different folders and would be able to would truly side-by-side.

    Branch

    Create a new branch in TFVC and map it in the same workspace. TFVC will simply create a new directory for the new feature branch. The isolation isn't absolute, so this could cause you to check in changes in two different branches at the same time.

    Remap

    With different branches you can remap the existing workspace to different server paths and then perform a get operation. To ensure that you're in a state matching the server you can run tf vc scorch to ensure it completely matches the version on the server.

    Git-Tfs

    If you're used to git, you could use git tfs to create a local git repo from a TFVC repository and you get a lot of the benefits you're used to. (get it here)