Search code examples
tfstf-clitfvc

TFS equivalent of "hg cat"?


There is one file I want to get from TFS. In the same situation in Mercurial I would just do hg cat.

Is there an equivalent to hg cat in TFS?

I was trying the following command line:

tf get $/dev/components/log.zip

But it fails with:

No appropriate mapping exists for $/dev/components/log.zip.

How do I do this?


Solution

  • TFS needs a workspace to have a mapping between the server repository and your local machine. If you already defined a workspace that includes $/dev/components/log.zip, then switch to that folder in the command line tool.

    If you want to get the file to the folder where you are at the moment, you need to create a new workspace. This can be done in Team Explorer or by using tf.exe:

    tf workspace /new logZipWs /collection:http://tfsserver:8080/tfs/DefaultCollection
    

    Now you have a workspace, but you need to map the server path to the local folder:

    tf workfold /map $/dev/components . /collection:http://tfsserver:8080/tfs/DefaultCollection /workspace:logZipWs
    

    Now your command should work. But the creation of workspaces is much easier using the Team Explorer.

    When you're done, make sure you remove the workspace, so it's unregistered from the TFS server (TFS tracks workspaces both on the server and on the client):

    tf workspace /delete logZipWs /collection:http://tfsserver:8080/tfs/DefaultCollection