30

I was developing team project and suddenly realised that i've made so many changes, that i need create branch.

I've never used branching in TFS and when i saw "Branch\ "From Workspace version" i thought that's, what i need. But this option doesn't act as i supposed.

How can i create new branch, from my "LOCAL COPY of Project" and include all local changes"? The option that I mentioned above creates something like branch from...i don't know exacly from what, but i know for sure, that not from my local version with all changes. As i noticed, generated branch doesn't have files and project which i added.

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
Simon
  • 2,329
  • 4
  • 30
  • 49

4 Answers4

25

What I would do is:

  • Shelve your work
  • Branch from the appropriate source folder
  • Use TFS Power Tools to unshelve to a different location
  • Check in.

That way, you get a nice clean branch, and you get a record of the changes you have made.

Robaticus
  • 22,857
  • 5
  • 54
  • 63
  • 1
    The command for the unshelve would be something like this --> tfpt unshelve /migrate MyShelveset /source:$\project\trunk /target:$\project\branch – Richard Banks Sep 17 '10 at 00:48
  • 1
    that works for me: tfpt unshelve /migrate MyShelveset "/source:$/project/trunk" "/target:$/project/branch" – Shrike Feb 21 '11 at 14:20
  • 8
    If the message "Unable to determine the workspace" is printed after executing the tfpt command, it could be because one is not currently in the local target folder (_cd _). – HenrikW Apr 11 '13 at 09:44
  • I also had to remove double quotes from the source and target branch, otherwise I got "The server path component of /source:serverpath was not a valid server path.". I also got "No shelvesets found" because I had double quotes around the shelveset name. I hope this helps someone – Sue Maurizio Sep 22 '17 at 08:24
12
  1. Download and install TFS Power Tools
  2. Shelve your work and remember the name
  3. Create your destination branch from the trunk you've been working in
  4. Map your new branch and get a local copy of the code
  5. Open Windows PowerShell and change to the directory of the original source code
  6. Run the following command replacing the Shelve set name and directory structure with your own:

    tfpt unshelve /migrate "MyShelveset" "/source:$/project/trunk" "/target:$/project/branch" 
    

(quotes around shelveset name are required if it contains spaces)

This should help you avoid some of the problems I ran into when I was trying to follow the original instructions.

Jakub Januszkiewicz
  • 4,380
  • 2
  • 37
  • 54
Kevin T
  • 196
  • 1
  • 4
  • 1
    I switched to the GIT long time ago and I won't come back to TFS, but thx for advice, it could be useful for someone. – Simon Jan 31 '13 at 10:15
3

Robaticus's answer is correct, but I wish to add some detail that I haven't seen explicitly stated elsewhere. I just had to do this and it acted like it was working but it wasn't. It would pretend to automerge or copy, but no files were created, and no checkouts were made in the new branch. An error should be raised, but none appears.

It turns out that the quotes around the source and target are optional if the paths have no spaces, but they are required if spaces exist.

Here's a template:

tfpt unshelve MyShelfsetName /migrate "/source:$/MyPath/My Path with spaces/MyBranch" "/target:$/MyPath/My Path with spaces/MyOtherBranch"
James
  • 377
  • 4
  • 7
0

You may want to try this one: I am assuming you are using Eclipse IDE and TFS Plugin. You need to be a TFS Administrator for the project.

  1. Open the project in work-space and right click on it
  2. you will notice "Team" in the menu.
  3. select "Share Project" in the extended menu of "Team"
  4. enter team Foundation Server details to connect it and select the appropriate Branch/Project to put your changes. You can also create a new folder by TFS Control Panel.

  5. Share the project in the selected branch/folder.

(THIS IS JUST ADDING PROJECT TO TFS-YOU NEED TO CHECKIN NOW)

  1. right click on the project again. in the "Team" menu you will find checkin changes option.
  2. click on it and your changes will be sent to Server.

Cheers!

Vincent Lal
  • 103
  • 1