Reputation: 1837
I can use a hand coming up with the right way to do this. I've got a TFVC style repository in which there are several branches. I want to move the entire thing over to git. I'm using git tfs (https://github.com/git-tfs/git-tfs) to export the TFVC stuff to local git repos, but the history is too complex and therefore I cannot export all of the branches at once. That in itself is not a problem since we also want to migrate to a different branching strategy whilst at it.
What the plugin does allow me is to export each individual branch with a subset of its history to a local git repo. So I end up with local repos for "master" and one for every release that has been stored in TFVC.
Now I want to commit these into a single new git repo. The master should go into a new master branch and for each release I want to create a branch "releases/release-xyz". How can I commit all of the code + history from each local repo into the right branch in the new repo? I found bits and pieces adding a remote and pushing each branch, but I want to make sure that I'm not forgetting anything here. I don't care about the merging history between the branches, as long as the exported history for each branch itself is intact.
So, exported structure:
folder A (master)
folder B (release-abc)
folder C (release-xyz)
And target structure:
repo/master
repo/releases/release-abc
repo/releases/release-xyz
Upvotes: 1
Views: 459
Reputation: 388293
What you basically need to do is create a new central repository which will be the target of this migration.
You then add this repository as a remote to every one of your individual repositories. Then you can just push to it using e.g. git push newrepo master:releases/release-abc
. This would push the master branch of the “abc” repo to the new repository’s releases/release-abc
branch.
Once you are done with all your individual repositories, the central repository will have all the changes in its branches.
Note that depending on whether or not git-tfs managed to do that, some commits might be the “same” without having the same id (I don’t remember if git-tfs properly and deterministically reconstructs the commits). In that case, you might need to clean up afterwards to make sure that the branches have common ancestors. You can use rebasing here to patch them back together properly.
Upvotes: 1