Tuesday, 23 July 2013

Creating a branch out of your pending changes on Trunk in TFS

I have been working on our Trunk branch when I have been told that my changes aren't going to be in this release. Luckily I haven't checked in, however I wanted to move all my stuff onto a separate branch so I can do my daily check-ins as per usual.

This is very easily solvable in SVN, however in wold of TFS not so much.

After some Googling I found this:
Unshelve changes onto another location
It is a very good guide however it misses some vital steps.

  1. Create a shelve out of your pending changes.
    1. Open your pending changes.
    2. Click Shelve (make sure you tick all files you want to move across). Make note of shelve name.
    3. Now you will need to do a full backup of your code in form of another shelve set.
    4. This time create shelve but check all files.
  2. You will be required to revert all your changes on branch/trunk that you have just used to create shelve. (You can also create a physical folder copy if you really worried about loosing your changes).
    Note: Without this step (ie. changes still pending on trunk) power tools wouldn't un-shelve to my new branch.
    1. Open your pending changes.
    2. Select all files
    3. Right click and select Undo...
    4. Make sure that there are no pending changes.
  3. Create another branch based.
    1. Right click your current branch and select "Branching and Merging"
    2. Select "Branch"
    3. Name it accordingly.
  4. Follow guide on Unshelve changes onto another location to restore to newly created branch.
I hope that works for you!

3 comments :

  1. Great ! Great help! I was encountering “An item with the same key has already been added.” when running tfpt command. Now it solved by Undo pending changes for Trunk as well. Thanks

    ReplyDelete
  2. Yeah had exactly the same problem!

    ReplyDelete
  3. Thanks! I had exactly the same problem :)

    ReplyDelete