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.

  • fatal error when pushing TAG to server
  • Team Explorer + Visual Studio Online + Git out of sync
  • Can Renaming the Main Branch in TFVC Orphan Child Branches?
  • Apply specific changeset from one TFS instance to another
  • TFS Git create repo - “User must become compliant”
  • Does TFS log undo checkouts?
  • 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.

  • can we Commit on Branch that's already been merged with master?
  • Git rebase from multiple branches not getting changes
  • Is there a way to make git automatically retry commands if index.lock exists?
  • Can you undo 'git reset --hard HEAD' if never having made a commit?
  • Unable to switch to local branch from master
  • How to compare two source trees for differences/changes on win32?
  • 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.