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

☆樱花仙子☆ 提交于 2020-01-02 07:17:48

问题


I'm using git-tf to push to a TFS project. Sometimes, when I try to check one or more commits into TFS, I get a message like this:

Connecting to TFS...
Checking in to $/MyProject: 0%
git-tf: Could not lock $/MyProject

What does this mean? What's keeping me from locking? And how can I fix this?


回答1:


Why it happens

With standard TFS usage, you're only checking in one commit at a time. But with Git, you could have a series of commits that you push all at once.

Because of that, git-tf strives to keep your set of commits atomic. 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.

How not to fix it

You'll see the --no-lock argument recommended in some places:

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.
  2. Run TFS Sidekicks.
  3. Navigate to Tools > Status 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.
  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.
  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". Now try your git tf checkin again, and it should work correctly this time.


来源:https://stackoverflow.com/questions/23090590/git-tf-tells-me-could-not-lock-when-checking-in-how-can-i-fix-it

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