Using TFS command line tf.exe how can I copy a repo to a folder location of my choice?

北城余情 提交于 2021-01-27 14:27:48

问题


I have stared using TFVC for my MSVS 2015 C++ project. I am used to command line repos like git/svn, where I can simply do a checkout/clone, etc... and copy the files to any folder I like.

So, I have checked out my workspace to a mapped location (c:\myworkspace) via the MSVS2015 GUI. But now I want to to run my auto test script, which will copy the latest files from the repo to the current directory (e.g. c:\autorun). The auto test script builds and tests and generates results etc... But I don't want it to just over-write what I have in my workspace in case someone else has added a change.

I want it to go to a different folder of my choice.

In Git I would just navigate to the folder (cd c:\autorun) and then do git clone <repo-path>. But I can't see how this is possible with TFVC's workspaces.

So far I have started to modify my script that worked with git to get this:

' Clean any existing files:
rmdir /S /Q <projname>

' Checkout project
tf checkout <projname> /recursive

' Do other stuff (build test etc...)

But this only works in my c:\workspace - and I don't want to delete/overwrite my local changes.


回答1:


You can create a new (temporary) workspace using

cd temp
md newfolder
tf vc workspace /new ...
tf vc workfold /map $/Project/Folder c:\temp\newfolder
cd newfolder
tf vc get . /recursive
tf workspace /delete

Or you can use the little utility written by Neno Loje, TfsExport.

Update From OP

Assuming that I start in the folder that I want to extract my projects into. I used the following:

tf dir shows the repos I have:

D:\sandbox\tfs-test > tf dir
$/:
$tfsRepo1 
$tfsRepo2
$tfsRepo3 

I just want the first two repos:

tf vc workspace /new /noprompt cit
tf vc get tfsRepo1 /recursive
tf vc get tfsRepo2 /recursive

Then to tidy up:

tf workspace /delete cit /noprompt
rmdir /S /Q tfsRepo1 
rmdir /S /Q tfsRepo2

Note the use of /noprompt in various places so that there is no user interaction required.



来源:https://stackoverflow.com/questions/41575742/using-tfs-command-line-tf-exe-how-can-i-copy-a-repo-to-a-folder-location-of-my-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!