TFS - Create a branch from local working copy

2020-07-10 07:28发布

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.

1条回答
欢心
2楼-- · 2020-07-10 08:04

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 ;).

查看更多
登录 后发表回答