4

I used https://stackoverflow.com/a/13710811/260865 to get a tfs repo with branches in one git repo and it works fine for a couple of branches. But I wasn't able to init all branches because of:
"C:\tmp\Main>git tfs branch --init --authors=C:\tmp\authors-file.txt $/someproject/Branches/7.2.0 The name of the local branch will be : Branches/7.2.0 error: The root changeset 26907 have not be found in the Git repository. The branch containing the changeset should not have been created. Please do it before retrying!!"

or

C:\tmp\Main>git tfs branch --init --authors=C:\tmp\authors-file.txt $/someproject/Releases/7.0.0.1 The name of the local branch will be : Releases/7.0.0.1 An unexpected error occured when trying to find the root changeset. Failed to find root changeset for $/someproject/Releases/7.0.0.1 branch in $/someproject/Main branch (renamed branch issue: https://github.com/git-tfs/git-tfs/pull/299)

TFS says that 7.0.0.1 is a child branch of Main.

Environment: git-tfs version 0.17.1.0 (TFS client library 11.0.0.0 (MS)) (32-bit) C:\tools\gittfs\git-tfs.exe

Has someone a solution for that?

Community
  • 1
  • 1
mawl
  • 453
  • 1
  • 6
  • 16

3 Answers3

2

The problem is caused by the branch having been renamed. There is a issue for this here but it has not yet be resolved.

init-branch does not handle TFS branch renames

If I create a branch in TFS from my Trunk and then rename the branch, when I attempt to execute init-branch on the renamed branch it does not find the correct changeset and complains that the original does not exist in the Git repository

“In TFS 2010 behind the scenes a rename is actually a branch and delete process, this meant we ended up with the new branch, but also a deleted branch of the old name. This is not obvious unless you have ‘show deleted items in source control explorer’ enabled…” That's the reason why git-tfs can't handle this case because git-tfs can't init a branch when the parent branch has not been inited before :( It's the 2nd step of what I've planned to do to better handle merge changesets and to allow automatically init a parent branch when root changeset not found (after #363 is merged).

But it need a big refactoring (need to move a lot of methods from one class to another)...

Community
  • 1
  • 1
Adam Gordon Bell
  • 3,083
  • 2
  • 26
  • 53
1

I have found a workaround that allows you to clone all branches even if they have renamed. As Adam mentioned, renamed branches are deleted and recreated, and we need the "parent" commits to be cloned before the children.

1) Find a list of all deleted branches I use Visual Studio -> Source Control Explorer -> click Show Hide Deleted Options toggle icon

2) In Ancestor Order, git tfs branch --init $\Project\Branch_Location each deleted branch

actual_kangaroo
  • 5,971
  • 2
  • 31
  • 45
1

The development made to support branch rename is now merged in master (but not yet released. Will be with the next release that should be 0.21).

It should solve most of the cases of rename (but with Tfs we are never sure :( ). Feel free to test and report case that don't work...

Philippe
  • 28,207
  • 6
  • 54
  • 78