Discarding changesets in TFS

We’ve recently updated our branching strategy at work and now have a Main branch and up to six branches which will each usually only have one work item on.  Once a work item is released to live the branches are forward merged from Main.  More recently I upgrade the database solution in Main and all the branches to SSDT for VS2012.  Each branch was manually upgraded so the changeset that contained the upgrade on Main wasn’t required to be forward merged into the branches.

You can use the following command to discard any unwanted changesets so they don’t appear in the list of changesets in the merge wizard in TFS.

tf merge "$/sourcePath/Main/Data" "$/targetPath/Branches/BranchA/Data" /discard /recursive /version:C20144~C20666

tf.exe can be found in C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE

If you have a batch of changesets that you want to discard, view them in the merge wizard in TFS and get the start and the end changeset numbers.  These are the two values you use in the /version tag prefixed wth a “C”.  If there is only one changeset you still need to specific it as a range, e.g. /version:C20144~C20144.

This seems to check out all the files that you would be merging if you weren’t discarding the changesets and you’ll need to check them in.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s