Reputation: 1019
I need to migrate a git repository to tfs git. This is my first time to migrate and it is important to keep the historical data intact. any idea how to do so?
Upvotes: 1
Views: 290
Reputation: 30382
Which version of TFS do you use? If you are using TFS 2017 Update1 or later version, then you can Import a Git repo in TFS directly.
For earlier version, you can follow jessehouwing or Mark's answer. And personally I think git clone --mirror source
it's much better.
You can also reference this thread : https://gist.github.com/niksumeiko/8972566
Upvotes: 0
Reputation: 114731
If you want to push all tags from the remote, they won't transfer from local clone, unless you've pulled them explicitly and then pushed them explicitly. That's what --mirror helps with.
git clone --mirror source
git push --mirror target
does magic. Full documentation can be found here. Adding a remote to a local repo and pushing will push the current branch and it's history, but it may not push all objects in the current master repository and it will not push all tags and labels over if they weren't present in your local clone.
Import repository helps because it saves doing it locally and can pull directly from the source, this can be much faster than creating a local repo and then pushing it along. It's supported in VSTS, TFS 2017u1+ and TFS2018. But it does require a direct line of sight between both servers and may require you to setup alternate credentials or a Personal Access Token.
Local clone method:
LOCAL <- SOURCE
LOCAL -> TARGET
Import repository option:
TARGET <- SOURCE
Upvotes: 3
Reputation: 45659
Migrating to a tfs git repository is the same as migrating to any other git repository. In the following, you need (a clone of) the source repo locally, and the git repo in tfs will become the remote.
So first you find a URL for the remote. You can get this from the TFS web UI; it should give it to you in the instruction page you get when first creating the repo, or if the repo already exists in tfs, you can click the "clone" button to get the URL.
Then you add this as a remote to the local repo.
git remote add tfs url/of/remote
Then you push your refs to the remote; git will send complete histories automatically.
git push --all tfs
Upvotes: -1