简体   繁体   English

登记时,git-tf告诉我“无法锁定”;我该怎么解决?

[英]git-tf tells me “Could not lock” when checking in; how can I fix it?

I'm using git-tf to push to a TFS project. 我正在使用git-tf推送到TFS项目。 Sometimes, when I try to check one or more commits into TFS, I get a message like this: 有时,当我尝试将一个或多个提交检入TFS时,我收到如下消息:

Connecting to TFS... 连接到TFS ......
Checking in to $/MyProject: 0% 签入$ / MyProject:0%
git-tf: Could not lock $/MyProject git-tf:无法锁定$ / MyProject

What does this mean? 这是什么意思? What's keeping me from locking? 是什么阻止我锁定? And how can I fix this? 我该如何解决这个问题?

Why it happens 为什么会这样

With standard TFS usage, you're only checking in one commit at a time. 使用标准TFS时,您一次只能检入一个提交。 But with Git, you could have a series of commits that you push all at once. 但是使用Git,你可以进行一系列的提交,你可以同时推送所有提交。

Because of that, git-tf strives to keep your set of commits atomic. 因此,git-tf努力使你的提交集保持原子性。 If someone checks in while you're checking in, the history can get mixed up; 如果有人在您办理登机手续时办理登机手续,那么历史可能会混乱; it won't be merged properly. 它不会被正确合并。

To prevent this, git-tf temporarily locks the entire source tree while it checks in. It can't do this, though, if somebody else has parts of the source tree locked already. 为了防止这种情况,git-tf会在签入时临时锁定整个源树 。但是,如果其他人已经锁定了源树的某些部分,则无法执行此操作。

How not to fix it 怎么解决它

You'll see the --no-lock argument recommended in some places: 你会在某些地方看到--no-lock参数:

git tf checkin --no-lock

This is not a good solution. 这不是一个好的解决方案。 It ignores the potential scrambled-history problem instead of solving it. 它忽略了潜在的扰乱历史问题,而不是解决它。

How to fix it 如何解决它

  1. Based on the version of TFS you're using, download and install the appropriate version of TFS Sidekicks . 根据您正在使用的TFS版本,下载并安装适当版本的TFS Sidekicks
  2. Run TFS Sidekicks. 运行TFS Sidekicks。
  3. Navigate to Tools > Status Sidekick. 导航到工具>状态Sidekick。
  4. Clear the User name field. 清除用户名字段。
  5. Set a date range sufficiently wide to encompass the whole history of your project. 设置足够宽的日期范围以包含项目的整个历史记录。 You can filter the Project name field if you like. 如果愿意,您可以过滤项目名称字段。
  6. Click Search. 单击搜索。 You'll get a list of all checked-out files in the project. 您将获得项目中所有已签出文件的列表。
  7. Click on the Lock type column header to sort by that column. 单击“锁定类型”列标题以按该列排序。 Most files will probably have "None" in that column. 大多数文件在该列中可能都有“无”。 You're looking for any files that have "Locked" instead. 你正在寻找任何“锁定”的文件。 This is most common with binary files, because they can't be merged. 这在二进制文件中最常见,因为它们无法合并。 By default, TFS will exclusively lock them when they're checked out. 默认情况下,TFS将在签出时将其独占锁定。
  8. Once you find out which files are locked, go talk to the person who has them locked and negotiate getting them unlocked. 一旦找到锁定的文件,请与锁定它们的人交谈并协商解锁。 If the person no longer works there, you may want to have a TFS admin just remove the locks. 如果此人不再在那里工作,您可能希望让TFS管理员删除锁。
  9. Once all the locks are removed, hit Search again in TFS Sidekicks and you should see that all files have a lock type of "None". 删除所有锁后,再次在TFS Sidekicks中单击“搜索”,您会看到所有文件的锁定类型均为“无”。 Now try your git tf checkin again, and it should work correctly this time. 现在再次尝试你的git tf checkin,这次它应该正常工作。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM