Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I unshelve to a different branch in tfs 2008?

Let's assume that some developer in my team shelved his changes that he did in branch A. And I am working on branch B. Can I unshelve his changes into branch B? (By GUI or command prompt)

like image 863
spinodal Avatar asked Sep 22 '08 20:09

spinodal


People also ask

How do I Unshelve in Visual Studio?

Choose Unshelve Changes if you want to retrieve the changes in the shelveset into your workspace: For any file changes that you don't want to unshelve, open the context menu of the file, and then choose Exclude. If you want to delete the shelveset, clear the Preserve shelveset on server check box.

How do you merge Shelveset?

It allows you to merge(unshelve) a shelveset into a specific branch. Using Source Control Explorer in Visual Studio, get the history for any folder or file. Select one or more changesets in the list and right-click your selection. The context menu will now have a 'Merge...' option.


2 Answers

The Visual Studio Power Tools should let you do this.

C:\src\2\Merlin\Main>tfpt unshelve /? 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.  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)  /nobackup              Skip the creation of a backup shelveset 

For example to merge a shelve set called "Shelve Set Name" created on Branch1 to Branch2 use this:

>tfpt unshelve "Shelve Set Name";domain\userName /migrate /source:"$/Project/Branch1/" /target:"$/Project/Branch2/" 
like image 199
Curt Hagenlocher Avatar answered Sep 28 '22 05:09

Curt Hagenlocher


Alternative solution to tfpt that avoids having to merge each file manually

The problem with the tfs power tool is that you're doing a 'baseless merge' so have to confirm every file. I had a shelveset of over 800 files and I never trust the 'auto merge' button and didn't want to go through each file in turn - so I had to find another way!

  • Download and install the TFS Shelveset Sidekick.
  • The tool appears under 'Tools' in VS2010
  • Run the 'Shelveset Sidekick' tool, click Search to show shelvesets
  • Right click on your shelveset and select 'Export Shelveset'
  • Save to an empty location such as C:\temp\shelveset-name
  • Now have a complete directory structure containing JUST the new files

(Note: There's no progress bar when exporting - so if you have a large shelveset that takes a long time to export you'll just have to check in Windows Explorer (File>Properties>Size) that the files are still coming down if you think it's frozen).

You now just have to copy them over to the new branch with Windows Explorer.

This worked for me :

  • Checking out the whole solution first (in the new branch)
  • Close that solution
  • Take TFS offline from within VS (Tool to do this) - see below for why this is important...
  • Copy files over in Windows Explorer. The directory structure in c:\temp\shelveset-name will have to be renamed to correspond to the new branch. Tip: Make sure you copy to the right place!!!
  • Bring VS online
  • It should find all the changes and add the new files
  • If it asks you to bind the sourcecontrol be sure to verify the path is correct for the new branch.
  • Test - and then checkin the new files

Important: I've found that if you don't first take TFS offline then you'll end up with any new files (from your unshelves changeset) showing without a little red check mark and you'll have to exclude and include them again to get them to add. If anyone has an alternative solution to this problem I'd love to know - refreshing doesn't seem to work.

like image 39
Simon_Weaver Avatar answered Sep 28 '22 06:09

Simon_Weaver