Sunday, January 09, 2011

How to force undo checkout? #TFS

Sometimes you'd pop into cases where you find yourself in a situation where you have to force undo pending code changes of someone else (say a colleague who is no more around, or even temporarily) or your own pending changes if say your machine (along with your workspace on it).

Well, there a Visual Studio tool for that.. That's tf command-line utility, which you can look for in your VS directory under Common7\IDE..

Using tf has lots and lots of uses, here's a really LONG list of them. Note: there's 3 sub-lists for VS2005, 2008, 2010. But for our tiny problem here, we mainly have to options, I'm using here the most straight forward ones:

Undoing pending changes for a specific file:

That will need mainly main parameters to start with: The name/path of the file checkout, User name (of the user who did the checkout), and the Workspace in which the checkout was done (usually your machine name if you didn't create an new workspace).

You could have an issue with the third one (workspace name), so you might have to check the Workspaces command for more details, but generally a small command like the one below will do just ok in most cases:

tf workspaces /owner:UserName

Knowing the above you can easily undo the pending changes as below, note: parameters are in squiggly braces like {these}:

tf undo {file path} /workspace:{workspace};{username} /server:{TFS name/IP}

Of course the "/server" part can be removed if you're on the same server running TFS. An example with some data will look like:

tf undo $/myProject/myFile.cs /workspace:mySpace;FCIH\shady /server:FCIH_TFS

Deleting the whole workspace:

The other option is to delete the whole workspace, which in turn delete any related checkouts. A simple command for that could be:

tf workspace /delete {workspace};{username} /server:{TFS name/IP}

which with some example parameters might look like:

tf workspace /delete Shady-PC;FCIH\shady /server:10.0.0.2

UPDATE:

After a comment by Meligy, I think I needed to add this: Most of the above needs you to be logged in as an account with TFS admin privileges, check the exact required permissions for Undo, Workspace and Workspaces commands.

If you're not logged in as the appropriate account, you can append {/login:username, [password]} to provide the authorized username and password.

Meligy, also, mentioned another tool called TFS Sidekicks that can do similar stuff.

Saturday, January 01, 2011

The main thing

I was having a long walk/talk with a friend today when this came up:

“The main thing is to keep the main thing the main thing.” ~Stephen R. Covey

We first agreed that our major problem is that we don't keep the main thing the main thing.. Later we agree that may be the problem is that: we are not sure what our "main things" really are?

Disclaimer

All the opinions expressed on this blog are my own and don't necessarily represent my employer's positions, strategies or opinions.