Visual Studio创建多个/其他工作区 [英] Visual Studio creating multiple/ additional workspaces

查看:461
本文介绍了Visual Studio创建多个/其他工作区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从VS2010开始,我开始使用TFS.到那时,我已经创建了自己的TFS服务器(myname.visualstudio.com).我的问题是我在TFS网站上创建了一个新项目(带有仪表板的项目).然后,当我转到VS2017,并连接到该新项目时,它要求我进行映射并按预期进行操作.我不只是单击地图并获取"按钮,而是单击高级,以便可以配置所有内容.

I started using TFS since VS2010. By that time I already created my own TFS server (myname.visualstudio.com). My problem is that I created a new project on the my TFS website (the one with the dashboards). Then when I go to VS2017, and connect to that new project, it asks me to map and get it as expected. Instead of just clicking "Map & Get" button, I instead clicked advanced so that I can configure everything.

在工作区配置对话框中,我注意到 VS将其命名为"MYPCBLABLA_1" .如果我尝试删除"_1",VS会说"计算机blablabla上已经存在工作区blablabla ",并且不允许我使用现有的工作区名称.

On the workspace configuration dialog, I noticed that VS names it as "MYPCBLABLA_1". If I try to remove the "_1", VS says that "the workspace blablabla already exists on computer blablabla", and does not let me use my existing workspace name.

为什么这样做?我不能只使用1个工作区吗?从我对工作空间的了解来看,它是我的项目的容器,因此是不同的工作空间,不同的项目集.但是他们到底是什么?

Why does it do so? Can I not use only 1 workspace? From what I understand of workspaces, it is the container of my projects, so different workspace, different set of projects. But what are they really?

其他信息: 我不知道这是否有帮助,但是在过去,我曾经对PC进行过多次格式化,但不确定重新格式化后使用VS时是否会影响映射或工作区名称.

Additional info: I don't know if this helps but on the past, I used to format my PC many times, I'm not sure if that affects the mappings or workspace names when I use VS after reformatting.

推荐答案

工作空间可能是TFVC中最难理解的功能.您说对了,这是一种从TFVC存储库中隔离不同文件集的方法.

Workspaces are maybe the least well-understood feature in TFVC. And you are right in saying they're a way to isolate different sets of files from a TFVC repository.

许多人为特定项目或一组解决方案配置新的工作空间,但让我们看一下可以详细使用工作空间的一些方式:

A lot of people configure a new workspace for a specific project or set of solutions, but let's look at some of the ways workspaces can be used in detail:

  • 修补程序:您可能需要为当前发生的事情创建修补程序,但是现有工作区中有待处理的更改.除了搁置这些更改,您还可以在错误的版本上执行获取特定版本",也可以创建一个新的工作区来解决此特定问题.完成修复后,您可以继续使用其他工作空间,而无需执行任何操作.
  • 实验:您可能需要进行一些重要的重构,重组源代码控制或其他一些影响很大的操作.在新的(临时)工作区中执行此操作可帮助您避免弄乱正常的工作区域.
  • 查看其他人的更改:在查看其他人的更改时,您可能需要一个本地副本,以便可以运行,注释和使用其他人的代码.无需将这些更改带到您自己的工作空间中,您可以轻松地将它们带入一个临时工作空间,然后可以安全地将其删除.
  • 在进行其他更改时执行合并:正在处理一项新功能时,可能是某些情况,当需要发布发行版时,已经有一些更改合并回了另一个分支.为了准备此版本,而无需在当前工作空间中进行更改或覆盖正在进行的工作,通常更容易在临时工作空间中执行此类发布活动,这样您便知道工作总是在确切的版本上完成在源代码管理中.
  • 防止对重要分支的意外更改:通过将生产分支放在单独的工作区中,您不会意外地将诸如Development和Main的更改合并到单个签入中.由于Visual Studio通常会自动选择工作区中所有未决的更改,因此这可能会导致对master/main分支的意外更改.我已经写了一个签入策略来防止这些问题,但是拥有单独的工作区是一个更安全的解决方案.
  • 与同一工作站/服务器上的多个开发人员一起工作:在某些组织中,开发人员使用远程桌面到中央强大的服务器进行更改.为了确保每个开发人员都有自己的文件集,每个开发人员都有自己的工作区.另一种方法是将工作区设为公共,这允许多个开发人员使用同一工作区文件夹.但这通常会导致各种意外问题.
  • 浏览旧版本的代码:如果您需要将旧版本与新版本进行比较/比较,通常可以摆脱Visual Studio中的文件夹差异视图,但是如果需要进行更彻底的比较,您可能希望在TFVC存储库中有2个相同文件夹的副本.创建两个工作区将使您可以在本地磁盘上拥有同一文件夹的两个不同版本.
  • 为合并或标签准备特殊版本:您可以合并和标记一组文件的工作区版本.您可以创建一个工作区,然后使用获取特定版本来获取特定文件的特定版本,这些都可以来自不同的变更集版本.满意后,您可以执行标签或合并或分支操作,以将该特定工作区版本配置存储在服务器上.
  • Hotfixes: you may need to create a hotfix for something happening now, but you have pending changes in your existing workspace. Instead of shelving these changes, performing a "Get Specific version" on the bugged version, you can also create a new workspace in which to solve this particular problem. After completing the fix you can then continue working with the other workspace without needing to do anything.
  • Experiments: you may want to do some major refactoring, restructure source control or some other highly impactful operation. Doing this in a new (temporary) workspace helps you prevent messing up your normal work area.
  • Reviewing other peoples changes: When performing a review on another person's changes, you may want to have a local copy so you can run, annotate and play with the other person's code. Instead of taking these changes into your own workspace, you can easily bring these into a temporary workspace, which you can safely delete afterwards.
  • Performing a merge, while you are working on other changes: It may be the case that you're working on a new feature an already have some changes merged back to another branch when a release needs to be shipped. In order to prepare this release, without picking up changes or overwriting work in progress in your current workspace, it's often easier to perform these kinds of release activities in a temporary workspace, that way you know that the work is always done on the exact version in source control.
  • Preventing accidental changes to important branches: By putting your production branch in a separate workspace, you can't accidentally combine changes from say Development and Main into a single check-in. Since Visual Studio often auto-selects all pending changes in the workspace, this may cause unintended changes to your master/main branch. I've written a Check-in policy to prevent these issues, but having separate workspaces is a much safer solution.
  • Working with multiple developers on the same workstation/server: in some organisations, developers use a remote desktop to a central beefy server to do changes. To ensure each developer has his own set of files, each developer gets his/her own workspace. An alternative is to make the workspace public, which allows multiple developers to use the same workspace folder. But this often leads to all kinds of unexpected issues.
  • Browsing an old version of the code: if you need to review/compare an older version to a new one, you can often get away with the folder diff view in Visual Studio, but if you need to do more thorough comparisons, you may want to have 2 copies of the same folder in your TFVC repo. Creating two workspaces will allow you to have two different versions of the same folder on your local disk.
  • Prepare a special version for merges or labels: You can merge and label the workspace version of a set of files. You can create a workspace and then use Get Specific Version to fetch specific versions of specific files, these can all come from different changeset versions. Once you're satisfied, you can perform the label or merge or branch action to store this specific workspace version configuration on the server.

如您所见,工作区允许您在一台计算机上进行并行开发,隔离更改等.

As you can see, Workspaces allow you to do parallel development on one machine, isolate changes etc.

如您所见,工作区是一个非常强大的概念.可用于许多操作.但是您需要彻底理解该概念.许多开发人员无法确切了解什么是工作区以及它们如何工作,而它们却缺少了TFVC的一些最强大的概念.

As you can see, workspaces are a very powerful concept. Usable for a lot of operations. But you need to understand the concept thoroughly. Many developers don't understand exactly what workspaces are and how they work, they're missing out of some of the most powerful concepts of TFVC.

在您的情况下,您现在有两个工作区.为了合并这些文件(如果需要),可以从_1文件夹中取消映射文件夹,然后在原始工作区中映射这些相同的文件夹.您还可以从TFS服务器中删除_1工作空间,然后更新原始工作空间的映射.

In your case you now have two workspaces. In order to consolidate these (if you want to), you can unmap the folders from your _1 folder and then map these same folders in your original workspace. You can also delete the _1 workspace from the TFS Server and then update the mappings of the original workspace.

请记住,工作空间存储在您的本地计算机上,但是TFS服务器还具有一个注册表,用于记录谁将哪些TFVC文件夹映射到了哪些工作站.因此,仅从本地磁盘中删除文件是不够的.您需要将这些更改保存到TFS服务器(更改映射后执行get操作后,此操作会自动发生.)

Remember that workspaces are stored on your local machine, but that the TFS server also has a registry of who mapped which TFVC folders to which workstations. So simply deleting files from your local disk is not sufficient. You need to save these changes to the TFS server (this happens automatically after performing a get operation after changing the mappings).

要检查哪些工作空间已注册到TFS服务器上的工作站,请使用:

To check which workspaces are registered to your workstation on the TFS server, use:

tf vc workspaces /computer:YOURWORKSTATIONNAME

然后使用删除旧工作区

// DELETE the local workspace
tf vc workspace /delete:WORKSPACENAME

// DELETE the workspace registration on the TFS server
tf vc workspaces /remove:WORKSPACENAME

这篇关于Visual Studio创建多个/其他工作区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆