Unshelving from one branch to another with Team Foundation Server Powertools 2008

Not so long ago I heard that it was impossible to unshelve a shelveset from the branch it was shelve on to a different branch. It is the way Team Foundation Server (TFS) works I was told. And indeed it is the way tfs works out of the box. I asked a colleague and he researched it and gave me the same message:  you cannot do it. He is right but I was not satisfied. I needed to find a solution. I either would write it myself or I would find an existing tool. And I found it. It can be done and the way to do it is with the unshelve command of the powertools for tfs.

The commandline of the unshelve command of this tool is:

 

tfpt unshelve – Unshelve into workspace with pending changes

Allows a shelveset to be unshelved into a workspace with pending changes.
Merges content between local and shelved changes. Allows migration of shelved
changes from one branch into another by rewriting server paths.

Allows changes from an already-unshelved shelveset to be undone, cleaning
up pending adds, and preserving other existing pending changes in the
workspace.

Usage: tfpt unshelve [shelvesetname[;username]] [/nobackup]
                              [/migrate /source:serverpath /target:serverpath]

shelvesetname          The name of the shelveset to unshelve
/nobackup                 Skip the creation of a backup shelveset
/migrate                    Rewrite the server paths of the shelved items
                                (for example to unshelve into another branch)
/source:serverpath     Source location for path rewrite (supply with /migrate)
/target:serverpath      Target location for path rewrite (supply with /migrate)
/undo                        Undo pending changes from an unshelved shelveset
/batchsize:num          Set the batch size for server calls (default 500)