Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Safely delete a TFS branch project

I'm currently reorganising our TFS source control for a very large set of solutions, and I've done this successfully so far.

I have a problem at the moment where I need to delete a legacy "Release Branch" TFS project that was branched for the old structure, and is no-longer required since I now host a release branch within the new structure.

This is an example of how the source control now looks after moving everything:

$/Source Project     /Trunk         /[Projects]     /Release         /[Projects]  $/Release Branch Project     /[Projects]     /[Other legacy stuff] 

So far I've found information that says:

  1. tf delete /lock:checkout /recursive TestMain to delete a branch.
  2. TfsDeleteProject to delete a project

tf delete seems to be only relevant when I need to delete a branch that is within the same project as the trunk, and TfsDeleteProject doesn't seem like it will delete the branch association from the source project (I hope I'm wrong, see below).

Can someone tell me if the above will work, and in what order I should perform them in, to successfully delete the TFS $/Release Branch Project while also deleting the branch association (from right-click $/Source Project -> Properties -> Branches)?

like image 788
Codesleuth Avatar asked Feb 26 '10 11:02

Codesleuth


People also ask

How do I delete a branch in TFS?

Right Click the Branch and click delete and then do a Check-in.

How do I permanently delete a file in TFS?

Use the tf destroy command to destroy, or permanently delete, version-controlled files from Team Foundation version control. The destroy action cannot be reversed. You must not destroy files that are still needed.

How do I delete a branch?

Deleting a branch LOCALLY Delete a branch with git branch -d <branch> . The -d option will delete the branch only if it has already been pushed and merged with the remote branch. Use -D instead if you want to force the branch to be deleted, even if it hasn't been pushed or merged yet.


2 Answers

Let me put the facts like this:

  • Within the context of the TFS source control system, "Delete" is a purely logical operation. You can Undelete at any time. You can have multiple deleted items occupy the same path over time, or even simultaneously. Branch relationships are preserved.
  • TFS "Destroy" is physical removal. To maintain database integrity, that means all entity relationships are removed too: changeset history, pending change records, shelved versions, merge history, and yes -- branch hierarchy. This Destroy feature was introduced in TFS 2008.
  • Destroy is the only operation allowed to alter the merge history table (from which branch relationships are determined). All other operations are strictly append-only.
  • TfsDeleteProject does its best to completely remove all traces of a project, the primary goal being to allow creation of a brand new project with the same name. Some TFS subsystems support physical deletes; some, such as WIT field metadata, only support logical deletes, even in TFS 2008 & beyond. In the case of source control, TfsDeleteProject invokes "delete" in 2005 and "destroy" in 2008+.
like image 83
Richard Berg Avatar answered Oct 17 '22 10:10

Richard Berg


In TFS you generally cannot permanently delete anything inside a team project (and TfsDeleteProject deletes a complete team project, but it is not clear if the source control content will actually be removed as a team project is just the top level of the source control tree).

A delete of a file, or whole set of files is just another tracked change, go back into history and it can still be seen.

You could use permissions to make it inaccessible to all. Or rename under an "Obsolete" team project.

EDIT (I finally remembered where this command was):

There is another option, from the command line: tf destroy:

Destroys, or permanently deletes, version-controlled files from Team Foundation version control.

I would expect this to remove the branch records to create the, now destroyed, files... but you might need to check.

like image 45
Richard Avatar answered Oct 17 '22 11:10

Richard