Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TFS - Create a branch from local working copy

I am trying to create a branch from my local workspace of a checked-out project.

Basic background: I checked out from the 'trunk' of a project and made a lot of changes.
I now want to check these changes into a new branch.

I created a new branch from within Source Control - but my workspace is still mapped to the trunk.

I followed the steps from an article I found here: Branch from local workspace

So I shelved my changes.
Created a branch.
Used TFPT to migrate from the trunk to the branch

tfpt unshelve "My uncomplete changes" /source:"$/MyRoot/MyProject-Trunk" /target:"$/MyRoot/MyProject-Branch" 

Everything looked to go smoothly (except it doesn't seem to support files which have been renamed - so I had to skip them)

But nothing has changed.
The branch is an exact duplicate of the trunk (no local changes included)
My workspace is still mapped to the trunk.
If I check-in, it checks into the trunk.

I tried to unmap the checked-out version I have, delete the local files, then check out the branch, then unshelve the changes I made, but I am flooded with

No appropriate mapping exists for $/Root/MyProject/Myfile.cs

It seems so simple, but TFS seems to add an extra layer of complexity to what was such an easy task in SVN...
Hopefully something stupid I am doing wrong.

Any help appreciated.

like image 291
jb. Avatar asked Mar 28 '12 12:03

jb.


People also ask

How do I create a local branch in TFS?

In Source Control Explorer, right-click the folder or file that you want to branch, point to Branching and Merging, and then click Branch. The Branch dialog box appears. In the Target box, modify the location and name for the new branch. You can also click Browse to specify a target.

Can we create branch in TFS?

Use the following procedure to create branches in TFS from Visual Studio. Connect to your Team Foundation Server (if you're not already) and open the team project you're working on. Go to the Source Control Explorer.

How do I create a local branch in Visual Studio?

To start, make sure you've got a previously created or cloned repo open. From the Git menu, select New Branch. In the Create a new branch dialog box, enter a branch name. For branch naming details, see Special characters in branch and tag names.


1 Answers

Try this:

  1. You need to include the new branch in your workspace in order to see any changes (otherwise you'll only see the checked-in versions). From Source Control Explorer, select Workspace->Workspaces... from the toolbar.
  2. Select Edit for your workspace and add a mapping to your new branch, e.g. Active|$/Root/MyProject-Branch|<My Local TFS Storage>\MyProject-Branch
  3. Run the command tfpt unshelve <shelveset> /migrate /source:$/Root/MyProject /target:$/Root/MyProject-Branch. It should create a new shelveset with mappings changed to your new branch.
  4. Try unshelving the new, migrated shelveset onto your new branch.

Btw, in TFS the term is to map a project/branch to a local storage, not 'check out' as in SVN. That term is used for those files you make changes to ;).

like image 197
Torbjörn Bergstedt Avatar answered Oct 03 '22 04:10

Torbjörn Bergstedt