如何确定本地工作区中当前有哪些变更集?
当然,我可以选择一个文件并查看其历史记录。但是,如果该文件最近没有更新,则其变更集可能比同一解决方案中最近更新的文件更旧。
我们可能犯的一个可能的错误是我们查看解决方案文件的历史记录,但是解决方案文件很少更改,除非您添加新项目/进行解决方案级别的更改。
最后,为了找出变更集,我需要记住最新更改的文件是什么并查看它们的历史记录。
有更好的方法吗?
How do I figure out what changeset I currently have in my local workspace?
Sure, I can pick one file and view its history. However, if that file was not recently updated, its changeset is probably older than the more recently updated files in the same solution.
One possible mistake that we may make is that we view the history on the solution file, however the solution file rarely changes unless you're adding a new project / making solution-level changes.
In the end to figure out the changeset I need to remember what were the latest files changed and view their history.
Is there a better way to do this?
发布评论
评论(5)
您的答案位于 Buck Hodges 的 MSDN 博客上:
noreferrer">如何从工作区的根(顶部)
Your answer is on a MSDN blog by Buck Hodges: How to determine the latest changeset in your workspace
from the root (top) of your workspace, in cmd perform:
使用 tf.exe 历史记录 的常见答案。 /r 直接可以工作,但速度可能非常慢。在我们的例子中,需要 10-15 秒。
我现在使用两阶段检查,首先检查一些任意文件的修订(我正在使用根文件夹中的文件)。
使用 powershell:
然后使用 /r 标志从根开始搜索,但限制搜索从上面找到的修订版本开始:
对于我们的代码库,这会将总时间从 10-15 减少到 1.4 -1.5秒。
据我了解,没有缺点或限制,但我认为在小型存储库中它可能会更慢。 - 我很高兴知道。
The common answer to use
tf.exe history . /r
directly does work, but it can be horribly slow. In our case it takes 10-15 seconds.I now use a two stage check, first checking the revision of some arbitrary files (I'm using the files in the root folder).
With powershell:
Then search from the root using the /r flag, but limit the search to start from the revision found above:
For our code base, this brings down the total time from 10-15 to 1.4-1.5 seconds.
As far as I understand there are no drawbacks or limitations, but I suppose it could be slower in a tiny repository. - I'd be glad to know.
运行 Visual Studio CMD(在我的例子中,VS2015 称为:“VS2015 的开发人员命令提示符”),然后进入项目文件夹并执行以下命令:
Run a Visual Studio CMD (in my case, for VS2015 is called: "Developer Command Promp for VS2015") and then get into your project folder and execute the following command:
如果您想使用 PowerShell (另请参阅;相当于@kroonwijk):
启用 tfs 管理单元(一次,如果还没有的话)
add-pssnapin Microsoft.TeamFoundation.PowerShell
使用 tfs cmdlet 获取当前变更集 ID
Get-TfsItemHistory; -Recurse -Stopafter 1 -Version W
If you want to use PowerShell (see also; equivalent to answer of @kroonwijk):
enable tfs snapin (once, if not already)
add-pssnapin Microsoft.TeamFoundation.PowerShell
use tfs cmdlet to get current changeset id
Get-TfsItemHistory <PATH_TO_PROJECT> -Recurse -Stopafter 1 -Version W
如果您确实不知道自己拥有什么版本,则应该使用其他建议的方法之一。如果您只是不确定是否有特定版本,或者不确定几个更改集,并且您更喜欢使用 VS TFS GUI 工作,则可以执行以下步骤:
如果没有区别:
或者,如果唯一不同的文件是您有待更改的文件:
这意味着您已使用相关版本的最新版本。
If you really have no idea what version you have you should use one of the other suggested methods. If you are just not sure if you have a specific version or you are uncertain between a few change sets and you prefer working from the VS TFS GUI you can fallow this steps:
If you have no difference:
or, if the only files that are different are files that you have pending changes in:
That means you are up to date with the version in question.