by Andreas

Team Foundation Server – Folder Locked for Check-Out

imageWhile doing some reorganizing in a client’s TFS structure I came across a common problem: files or folders are locked by a user that is no longer available. The error message says:

The item [file path] is locked for check-out by [user] in workspace [workspace]


In my case the files were locked by a user account from my previous Windows Server 2008 R2 image. To unlock all files for a given user account, open up the Visual Studio Developer Command Prompt (located under your Microsoft Visual Studio 20xxVisual Studio Tools folder). Run the following command, replacing [workspace] and [user] with your values:

tf lock /lock:none /workspace:[workspace];[username] /recursive $/


Note: You have to have Project Administrator or Team Foundation Administrator rights in order for this to work.

by Stian

TFS: Discard changes in merge

imagesWhen merging between two branches in TFS, you get a list containing specific changesets that have been checked into the source branch but not merged into the target branch. Sometimes these are changesets that you never want to merge into your target branch and they are just messing up for you (because at some point you are going to hurry through this wizard and accidentally  select “Merge all changesets”).

Well, no need to kill yourself yet: you can always discard these changesets and forget all about them. There is no way to do this in Visual Studio GUI, so you will need to fire up the Visual Studio Command Prompt.

Make sure you are in your workspace directory and write a command like:

tf merge $/project/branch $/project/trunk /discard /recursive /version:C666~C688

Version is FROM changeset ~ TO changeset. If you are only discarding one changeset, you would repeat the changeset like this /version:C666~C666.

It should also be mentioned that you are still required to check in the changes, even though there is essentially no change in the file content.

by Stian

Save Team Foundation Server credentials

TFSIf you are sick of typing the credentials to TFS in Visual Studio 2010 for each time you start it, try following these few steps:

Windows 7:

  • Start Menu -> Control Panel -> Credential Manager
  • Click “Add A Windows Credential”
  • Type in your internet/network address as your TFS server address (without any ports or subfolder), and username and password of your TFS account.

Windows Vista:

  • Start Menu ->Control Panel
  • User Accounts> Manage your Network Passwords
  • Click Add
  • Enter TFS server address
  • Enter your TFS username and password

Windows XP :

  • Start > Settings -> Control Panel
  • User Accounts -> Advanced> Manage Passwords -> Add
  • Enter TFS server address
  • Enter your TFS username and password.

This is it, Visual Studio will now stop bugging you and let you focus on doing your job!