75

I made changes to a lot of files, and in the meantime I figured I rather commit this untested code to a yet-to-be-created branch, so that users of the existing code base are not affected.

As I touched really many, many files and created and added new sub-projects etc., I want to avoid copying files and folders manually.

What's the easiest way to get this done in Visual Studio?

Schmuli
  • 743
  • 1
  • 6
  • 20
Evgeniy Berezovsky
  • 18,571
  • 13
  • 82
  • 156

1 Answers1

93

This functionality is provided using tfpt unshelve /migrate. To use it, follow these steps:

  1. Create a shelveset of your changes (from the UI, or tf shelve . /R)
  2. Create the new branch
  3. Download and install the Team Foundation Server Power Tools
  4. From a Visual Studio Command Prompt, run the following command: tfpt unshelve /migrate /source:$/TeamProject/Main /target:$/TeamProject/Beta

This will essentially re-write the paths in your shelveset to the new branch.

granth
  • 8,919
  • 1
  • 43
  • 60
  • 1
    Awesome, thanks. In the meantime, I did it the hard way. But I don't want to have to do it again, so I'll use your instructions next time. – Evgeniy Berezovsky Jan 19 '12 at 12:13
  • 13
    Run tfpt unshelve from a mapped directory to avoid 'Unable to determine the workspace' – tymtam Jan 25 '13 at 05:14
  • 14
    Also it is worth mentioning that after issuing this command you will be able to choose which shelveset to move. – tymtam Jan 25 '13 at 05:16
  • 7
    Another "worth mentioning": If you perform step 4 above and get `An item with the same key has already been added`, make sure you **UNDO** the changes on the source branch first. See [this article](http://www.lemisolutions.co.nz/2013/07/creating-branch-out-of-your-pending.html) Also, this is confirmed to work with TFS2012 – kaveman Nov 05 '13 at 23:03
  • 5
    Visual Studio command prompt wasn't sufficient for me; I had to actually `cd` into a workspace directory, and then do the full `"c:\Program Files (x86)\Microsoft Team Foundation Server 2010 Power Tools\TFPT.EXE" unshelve /migrate /source:$/blah/Trunk /target:$/blah/Branches/blah` Started the installer again and it does appear that I had installed everything fine. – James Skemp Nov 08 '13 at 22:40
  • Can this same process be used in merging from a branch back to main? I'm a little hesitant to try. – DavidTheDev Jan 04 '17 at 22:09
  • This worked. I'll just state that I am utterly shocked I needed to install "power tools" to accomplish this! – Paul Suart Feb 02 '17 at 12:03
  • If you still get 'An item with the same key has already been added', make sure you undo all pending changes across all branches, per http://stackoverflow.com/a/26430948/265570 – bkaid Mar 28 '17 at 17:39
  • [Chocolatey](https://chocolatey.org/) command to install TFPT and add it to your system PATH: `cinst tfpt` – Eric Eskildsen Jul 31 '18 at 18:11
  • 3
    This no longer works. TFPT.exe is no more. Any idea how to do this now? – Jordan May 15 '19 at 19:08