1

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!

Philippe
  • 28,207
  • 6
  • 54
  • 78
Dan Csharpster
  • 2,662
  • 1
  • 26
  • 50
  • 1
    Why do you want to migrate the root folder to branch? Even if the root folder is not a branch, you can also migrate the history by `git tfs clone $/myProject`. And what's the command did you use to "convert the root folder to a branch" while got the error? – Marina Liu Jun 18 '18 at 03:08
  • Thanks for the questions. I will update my question with those details – Dan Csharpster Jun 18 '18 at 11:08
  • I've provided an update to my question with this info, but basically because of the output of list-remote-branches, some users' comments I found on the interwebs and some of the output comments from the git-tfs tool. – Dan Csharpster Jun 18 '18 at 11:50
  • 1
    I have updated my answer to give you another information... – Philippe Jun 18 '18 at 13:39
  • @DanCsharpster `git-tfs clone https://mysite.visualstudio.com/ $/myproject1` will migrate all the versions of the TFVC repo into git default branch `master`. It will only show warning not error (as you found). And if you need to migrate certain TFVC branch, then specify the branch in `git tfs clone command`. – Marina Liu Jun 19 '18 at 09:00

1 Answers1

2

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.

Philippe
  • 28,207
  • 6
  • 54
  • 78
  • I've updated my question with this output as it is too long for a comment, but basically it lists several of the smaller branches and then tells me I should convert the root to a branch. – Dan Csharpster Jun 18 '18 at 11:58
  • Ah, gotcha! That was the missing piece I was unsure of. My client definitely wants their history. So I will need to convert their nested branches to folders and convert the root branch to a folder, right? Is there any downside to this? Is there any risk of flipping folders and branches? I don't want to compromise their repository. – Dan Csharpster Jun 18 '18 at 18:56
  • As I know, no, there is no bad side effect to convert a folder in a branch. If I remember well, you could convert it afterward and it will work, but I'm not sure. I hope so for you. – Philippe Jun 18 '18 at 21:41