Search code examples
visual-studiotfsversion-controlgit-tfs

How to convert a deleted regular directory into a branch in TFS?


I'm in the middle of migrating a repository from TFS to Git, and I'm using git-tfs.

I've already converted my Trunk branch using 'git tfs clone ...' successfully. When trying to 'git tfs branch --init' a related branch it fails with the error message: 'error: TFS branches $/foo/myrelatedbranch not found!'

This seem to be caused by the $/foo/myrelatedbranch no being a proper tfs branch. The 'branch' documentation (https://github.com/git-tfs/git-tfs/blob/master/doc/commands/branch.md) seem to be pretty clear on the related branch having to be a PROPER branch (https://github.com/git-tfs/git-tfs/blob/master/doc/commands/branch.md#merge-changesets-and-branches).

The branch $/foo/myrelatedbranch has been deleted a while back, so I'm not able to see the option 'Branching and Merging -> Convert to Branch' in the Source Control Explorer.

Is there any way of making this deleted directory a proper branch in TFS?

Using Visual Studio 2015 and TFS 2015


Solution

  • You can configure the Source Control Explorer to show deleted items:

    1. From the menu bar choose Tools, Options.
    2. On the Options dialog box, navigate to Source Control, Visual Studio Team Foundation Server.
    3. Select Show deleted items in the Source Control Explorer, and then choose OK.

    If you now open the Source Control Explorer, you can view the deleted folder and convert the folder to a branch.

    You can also rollback the changeset that deleted the folder. The rollback will create a new changeset where the changes are negated (so in this case, where the folder is added).

    If the problem still exists, you could just take a snapshot of the latest version and migrate that to Git.