January 19th, 2005

How to use shelving from the command line

Buck Hodges
Director of Engineering

Shelving is a really useful feature that was included for the first time with the Dec. CTP.  Shelving allows you to save your changes to a shelveset on the server.  The shelveset consists of the same kind of information that a checkin does, except that you aren’t checking in.  You don’t create a new changeset.  Rather, you create a space on the server that is your own that contains your pending changes, comment, etc.

You can choose to move your changes out of your workspace or you can keep your pending changes when you shelve.  Moving your changes is great when you need to stop working on your current changes, make a targeted fix, check in that fix, and then unshelve what you were working on before being interrupted.  Keeping your changes in your workspace is very useful when you want share a change (perhaps a fix for another developer prior to checkin) or have another person review your changes.

I’ll talk more about how works in upcoming posts.  For now, here are some commands you can use to explore shelving in the Dec. CTP.

Bring up a Visual Studio command prompt (Start -> All Program -> Microsoft Visual Studio 2005 Beta -> Visual Studio Tools -> Visual Studio Command Prompt), cd to a workspace directory with some pending changes, and try out some of the following.  If you need to create a workspace, you can create one with “h workspace /new MyWorkspace /s:yourtfsservername” and then pend some changes.

To shelve all of your changes in your current workspace, use
    h shelve MyShelvesetName [optional filespecs]

To unshelve an existing shelveset, use
    h unshelve MyShelvesetName [optional filespecs]

To shelve the changes and undo them in your workspace, use the /move option with /i (or uncheck “Preserve my changes” in the GUI).  The /move option also deletes pending adds since they get uploaded to the server — something a plain undo doesn’t (and can’t) do.
    h shelve /i /move shelvesetname [optional filespecs]

To delete a shelveset, use the shelve command.
    h shelve /delete shelvesetname

To see the changes in another user’s shelveset, use the status command (when the other user is in the same domain, you should be able to leave that off).
    h status /shelveset:shelvesetname;domainuser

To see the diffs for a shelveset, use the diff command (great for remote code reviews).
    h diff /shelveset:shelvesetname;domainuser

You can also see a list of all shelvesets with shelvesets command
    h shelvesets /owner:*

 

Author

Buck Hodges
Director of Engineering

Director of Engineering, Azure DevOps

2 comments

  • Alexandru Tomovici

    Hi Buck, this is fifteen years later. I am new to x++ and VS development tools. The question is how should we shelve labels ? I marked the file in my project and thought I shelved them but on a different development box they do not come over ? Thanks, Alex.