Convert changeset(s) to shelveset

It is possible to create a shelveset from a changeset with some limitations. I needed to rollback a change from a branch to remove it from a release but it wasn't in any other branch either so I wanted to keep the change in a shelveset. I achieved this as below:

  • Rollback the changeset and check in the rollback.
  • Rollback the rollback changeset. This gives me a set of pending changes containing the original change.
  • Shelve the pending changes.

You could apply this technique to the case described in the question but it would be a lot of manual effort as it would have to be repeated for every changeset. It would also generate a lot of mess in TFS as you would have to check in the rollbacks of the rollbacks too.


No, it's not possible. Changesets and shelvesets are different things, with different purposes. You could probably write a plugin to do what you're after (retrieve changeset, check out the files, shelve the files).


It's not impossible. Technically speaking you can do it, although you may not want to. I'll let the reader decide.

You may want to do this in a new workspace.

  1. Get the Changeset in question (new code)
  2. Move all the source to temp folder. (don't move the $tf folder). Source tree should now be empty.
  3. Get the previous Changeset.
  4. Mirror copy the new code on top of the old
  5. Do a Reconcile.

Now you can create the Shelveset.

If you are able to focus to a particular folder, then it will go faster, and you can automate it. Here's example command lines that will do this. I just tried it and it worked for me.

In this example, I point to a folder from the root called "Src". Change it your root folder.

md tmpws
cd tmpws
tf vc workspace /new /noprompt tmpws /location:local /permission:private

tf vc get "$/Src" /version:C2222 /recursive /noprompt

cd ..
md tmp
move "tmpws\Src" tmp

cd tmpws
tf vc get "$/Src" /version:C1111 /recursive /noprompt  /force /overwrite

cd ..
robocopy "tmp\Src" "tmpws\Src" /mir

tf vc reconcile /promote /adds /deletes /diff /recursive /noprompt

tf vc shelve /replace /noprompt mychange 

tf vc undo "$/Src" /recursive /noprompt
tf vc workspace /delete tmpws

cd ..
rmdir /q /s tmp
rmdir /q /s tmpws