简体   繁体   English

Team Foundation Client命令重置工作区

[英]Team foundation client command to reset workspace

Is there a command (or series of commands) to sync a TFVC workspace with the server, ensuring that what's on disk exactly matches what's checked in to the server. 是否有一个命令(或一系列命令)将TFVC工作区与服务器同步,以确保磁盘上的内容与检入服务器中的内容完全匹配。

tf vc scorch almost does what's needed, in that it syncs the client workspace with the server's version of that workspace, but if a new item's been created on the client and added to source control, though not yet checked in, that item remains after scorch is run. tf vc scorch几乎可以完成所需的工作,因为它会将客户端工作区与该工作区的服务器版本同步,但是如果在客户端上创建了一个新项目并将其添加到源代码管理中,尽管尚未签入,则该项目在烧焦后仍会保留运行。 NB: I'm using the TF Client version of scorch rather than the power tools version, as I'm working with VS2017 ( scorch is supported from VS2013 SP1), should that make any difference. 注:我使用的是烧焦的TF客户端版本,而不是电动工具的版本,因为我用VS2017工作( scorch从VS2013 SP1的支持),应该使任何区别。

Related, I'm aware that power tools includes a treeclean command; 相关的,我知道电动工具包括一个treeclean命令; however that only impacts items not under source control; 但是,这只会影响不受源代码控制的项目; not those added to version control but not checked in. https://adamprescott.net/2011/09/12/clean-tfs-workspaces-with-scorch-treeclean/ . 而不是未添加到版本控制中但未检入的内容。https://adamprescott.net/2011/09/12/clean-tfs-workspaces-with-scorch-treeclean/

The only way I can think of to achieve this is to delete ( tf vc workspace /delete /collection:"https://$MyInstance.visualstudio.com/DefaultCollection" $MyWorkspace ) & recreate ( tf workspace /new $MyWorkspace /collection:"https://$MyInstance.visualstudio.com/DefaultCollection" ) the workspace, before running a recursive get to repopulate the new folder. 我能想到的唯一方法是删除( tf vc workspace /delete /collection:"https://$MyInstance.visualstudio.com/DefaultCollection" $MyWorkspace )并重新创建( tf workspace /new $MyWorkspace /collection:"https://$MyInstance.visualstudio.com/DefaultCollection" ),然后运行递归获取以重新填充新文件夹。 However, that feels like the long-way-round for something which I'd assume would be simple... 但是,这感觉就像是漫长的尝试,我认为这很简单...

We're using TFVC rather than Git because we're working with Dynamics AX , which does not natively support Git . 我们使用TFVC而不是Git因为我们正在使用Dynamics AX ,它本身并不支持Git

The reason I want to delete such objects is because this script will run on a build server, where I want to ensure we build exactly what's checked in to source control. 我要删除此类对象的原因是因为此脚本将在构建服务器上运行,在此我想确保我们完全构建了检入到源代码管理中的内容。 Whilst in theory no one should be creating new objects on the build server, I don't like to rely on that assumption / want to make this script as robust as possible. 从理论上讲,没有人应该在构建服务器上创建新对象,但我不希望依赖于这种假设/想要使此脚本尽可能健壮。

I'd missed the undo command: TF.exe vc undo * /recursive /noprompt . 我错过了撤消命令: TF.exe vc undo * /recursive /noprompt

Running this command before running get and then scorch ensures that my workspace exactly matches the latest server version. 在运行get然后焦烧之前运行此命令可确保我的工作空间与最新的服务器版本完全匹配。

Here's the complete code used to sync the current workspace with the server. 这是用于将当前工作空间与服务器同步的完整代码。 NB: This command assumes that tf.exe 's directory is included in the path environment variable (or you can replace tf with "...\\path\\to\\tf.exe" ), that the current/working directory is mapped in source control, and that your tf credentials are cached (otherwise include the /login argument with username and password). 注意:此命令假定path环境变量中包含tf.exe的目录(或者您可以将tf替换为"...\\path\\to\\tf.exe" ),当前目录/工作目录已映射到源代码控制,并且您的tf凭据已缓存(否则,请在/login参数中添加用户名和密码)。 I've not included /all , '/overwrite', or '/force' on the get command, since scorch will cover this anyway; 我没有在get命令中包括/all ,'/ overwrite'或'/ force',因为scorch总会解决这个问题。 the main purpose of the get here is to ensure our workspace is "pointing at" the latest definition. get此处的主要目的是确保我们的工作区“指向”最新定义。

tf vc undo * /recursive /noprompt
tf vc get * /recursive /noprompt
tf vc scorch * /recursive /noprompt /diff 

NB: The vc above is superfluous / just ensures that were there a possibility for ambiguity the system would know to use tfvc 's version of the command instead of the git version. 注意:上面的vc是多余的/只是确保系统可能存在歧义的可能性,系统会知道使用命令的tfvc版本而不是git版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TFS PowerShell管理单元:如何读取Team Foundation工作区版本 - TFS PowerShell Snapin: How To Read Team Foundation Workspace Version Team Foundation Client未使用提供的凭据 - Team Foundation Client Not Using Credentials Provided 使用命令行连接到Team Foundation Service - Connecting to Team Foundation Service with command line 团队基础服务器的“客户端”和“WebApi”库之间有什么区别? - What is the difference between team foundation server's “Client” and “WebApi” libraries? MIcrosoft反馈客户端无法连接到Team Foundation Server - MIcrosoft Feedback Client can't connect to Team Foundation Server 如何从命令行连接到托管的Team Foundation Service - How to connect to hosted Team Foundation Service from command line 有没有办法轻松共享Visual Studio Online / Team Foundation Server的工作区设置(文件夹映射)? - Is there a way to easily share Workspace settings (folder mappings) for Visual Studio Online / Team Foundation Server? 云中的团队基础服务器? - Team foundation server in the cloud? Team Foundation Service中的报告 - Reporting in Team Foundation Service 使用 TF VC 命令替换“Team Foundation PowerTools”TFPT GETCS 命令 - Replacement for “Team Foundation PowerTools” TFPT GETCS command using TF VC commands
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM