Search code examples
version-controlazure-devopstfvcgit-tfs

TFVC and consequences of converting branches to folders


Setup:

I have a client with a TFVC source control repository. The root is a folder, not a branch. Scattered throughout the hiearchy are branches, sometimes 2, sometimes 3 levels deep. For using git-tfs to migrate the repository, I need the root to be a branch. However, when I try to convert the root folder to a branch, I get this error:

You cannot create a branch at $/myProject because a branch already exists at $/myProject/Releases/7.3/Metadata. 
If $/myProject/Releases/7.3/Metadata is not a branch convert it back to a folder and retry the operation.

Question:

Is there any impact to me "de-branching" some of those branches, turning them into regular folders, so that I can make the root a branch and then use git-tfs to migrate it? Could I possibly lose some of the history? Would I be risking corrupting the source control repository or losing any data? I'm trying to be very careful with the client's source code and not risk losing any data.

Thanks!

Update:

My justification for thinking I need to convert the root to a branch: * When created a simple test repository to try out the migration, and ran this command

git tfs list-remote-branches https://mysite.visualstudio.com/

I got this message

"No TFS branches were found!"

And on this github issue, it said I should switch to a branch, then I would see it and that worked. So I assumed the clone wouldn't work since it didn't show up in the list. Also, with the similarly structured test repo, when I ran git tfs list-remote-branches, I got:

TFS branches that could be cloned:

$/myproject1/Releases/7.1/Metadata [*]

$/myproject1/Releases/7.2/Metadata [*]

$/myproject1/Releases/7.3/Metadata [*]

$/myproject1/Trunk/Main [*]

Cloning root branches (marked by [*]) is recommended!

PS:if your branch is not listed here, perhaps you should convert its containing folder into a branch in TFS: -> Open 'Source Control Explorer' and for each folder corresponding to a branch, right click on the folder and select 'Branching and Merging' > 'Convert to branch'.

Based on that, I thought I had to convert it to a branch. The next command I ran was

git-tfs clone https://mysite.visualstudio.com/ $/myproject1

I thought this gave me an error when the root was a folder, but it just gave me a warning when I reran it just now. The folder structure was something like folder/folder/branch folder/folder/folder/branch/folder etc

warning: you are going to clone the whole repository or too high in the repository path ! => If you want to manage branches with git-tfs, clone one of this branch instead : - $/myproject1/Releases/7.1/Metadata - $/myproject1/Releases/7.2/Metadata

So it looks like the reponses are right. You can clone off the root without a problem. Thanks!


Solution

  • Don't convert your branch to a folder.

    What does the following command tell you to clone?

        git tfs list-remote-branches http://tfs:8080/tfs
    

    A doc on the subject : https://github.com/git-tfs/git-tfs/blob/master/doc/usecases/manage_tfs_branches.md#find-the-tfs-branch-to-clone-optional

    Edit: git-tfs is able to clone every folders in a TFVC Collection but if you want to clone the history with the branches, each folder should be converted as a branch.