When using GIT-TFS, a commit with a # before an item will automatically link that commit to that item in TFS. However, there are times when a remote branch that was used for development is deleted and the linked commits remain on the TFS item even though those commits no longer exist. How can these now-invalid links be removed other than manually?
Asked
Active
Viewed 194 times
1 Answers
0
Unfortunately, there is nothing built in. You would need to write code that iterated over the work items, got the links to the commits, checked the commits against the repo, and then delete the WIT links to commits that don't exist.

Buck Hodges
- 3,342
- 1
- 19
- 20
-
Do you know where I could find some sample code that iterated over TFS items? – cjbarth Feb 24 '15 at 13:19
-
1Here's a post that should get you started: http://blogs.msdn.com/b/dgorti/archive/2007/09/26/querying-on-workitem-links-through-the-api.aspx. Back when that post was written, collections didn't exist. So getting to the WorkItemStore object is what is shown in http://stackoverflow.com/questions/10748412/retrieving-work-items-and-their-linked-work-items-in-a-single-query-using-the-tf. Here's one more http://www.ewaldhofman.nl/post/2009/11/03/TFS-2008-API-Create-a-link-between-work-items.aspx. That should get you started. – Buck Hodges Feb 24 '15 at 14:44