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.

  • Similar program to Team Foundation Server
  • TFS: submit changes done locally in one branch to another branch
  • Team Foundation Server switch between branches
  • Difference between Team Foundation Server and Team Services
  • Capturing Non-Standard Powershell CmdLet Output for Flow Control
  • TFS: Merge best practices
  • 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.

  • What is the difference between all the different types of version control?
  • git-upload-pack: command not found, how to fix this correctly
  • Diffing a file against last Mercurial changeset, should it be different?
  • How do I extract and remove a merged branch in Git?
  • SQL version control methodology
  • Find the tfs path of merged branch
  • One Solution collect form web for “TFS – Create a branch from local working copy”

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

    Git Baby is a git and github fan, let's start git clone.