We have an internal server in a company for TFS which is contained in more than 100 projects. We are walking on the edge! Therefore the company made a decision to move all the projects to Visual studio team services (VSTS). Unfortunately, It cost so much time if we are gonna move the projects one by one.
I also tried Git-TF or Git-TFS but it was not successful and so frustrating. I got some errors every time and then I gave up.
Is there any way to move all the projects to VSTS at once or at least import them by VSTS? (For example, i import the Github projects directly from VSTS. But now instead of Github we have a computer as a server inside the company)
I appreciate that any suggestion or help.
If you want to have a high fidelity database migration, you should check #DenverDev's reply, he has provided correct links there.
If you only want to migrate a complete Git Repository from TFS to VSTS, you could try the steps in this blog:
Clone the Git repo with everything in it: git clone [tfs git url] --mirror
Add the new remote: git remote add vsts [vsts git url]
Push all the changes: git push vsts --mirror
This is a comprehensive script for automating the clone of all your git repos to your Azure DevOps project using powershell, and the TFS api. I'm going from TFS 2018:
# get all repositories
$TfsUrl = "http://tfs-server:8080/tfs/DefaultCollection/myProject/_apis/git/repositories?api-version=4.1"
$repos = Invoke-RestMethod -Uri $TfsUrl -Method Get -ContentType "application/json" -UseDefaultCredentials
# set the auth header from a PAT
$myPAT = "aaaaaabbbbbbbbbbbbcccccccccccdddddddd111111123"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("aaduser#domain.com:$myPAT")))
$headers = #{Authorization=("Basic $base64AuthInfo")}
# get Azure DevOps project id
$adoPURL = "https://dev.azure.com/myOrganization/_apis/projects?api-version=4.1"
$adoProjectId = ((Invoke-RestMethod -Uri $adoPURL -Method Get -ContentType "application/json" -Headers $headers).value | where {$_.name -eq "myADOProject"}).id
# loop through each TFS repository, clone it, and push it to your Azure DevOps project
foreach ($repo in $repos.value) {
Write-Host "cloning $($repo.name)"
# set to the root folder, and mirror clone the repo
Set-Location C:\clone_repo
git clone --mirror http://tfs-server:8080/tfs/DefaultCollection/myProject/_git/$($repo.name)
# create the new remote git repo in your Azure DevOps project
$json = '{"name":"' + $($repo.name) + '","project":{"id":"' + $adoProjectId + '"}}'
$vUrl = "https://dev.azure.com/myOrganization/_apis/git/repositories?api-version=4.1"
Invoke-RestMethod -Uri "$vUrl" -Body $json -ContentType "application/json" -Method POST -Headers $headers
# push the morrored repo to the remote
Set-Location "$($repo.name).git"
git remote set-url --push origin https://dev.azure.com/myOrganization/myADOProject/_git/$($repo.name)
git push --mirror
}
Microsoft provides a fairly comprehensive guide for migrating from TFS to VSTS.
Migration Options
Migrate to Visual Studio Team Services
If you have already tried this and are having specific errors, please post additional information.
Related
Before posting this question I have looked through all the similar ones. Finding no workable solution I am asking for help.
Thanks in advance!
I am trying to copy the repository from one tenant to another one using the following approach:
(done) Download the tool: Download Microsoft Git-TF for Visual Studio Team Foundation Server and Visual Studio Online from Official Microsoft Download Center
(done) Download Git-TF and Git-TFS (done with using git-tfs)
Clone an existing TFVC repo to my local machine as a Git repo using the Git-Tf tool: git-tf clone https://dev.azure.com/myorg/ "$/mysourceteamproject/mysourcebranch" --deep git-tf is no longer supported so I used git-tfs here. git-tfs clone https://dev.azure.com/myorg/ "$/mysourceteamproject/mysourcebranch" --deep
(done) Cd into the directory that the code was cloned into and push the local Git repo to any empty remote Git repo (this will be used as a temporary repo during the migration) git remote add origin https://user#dev.azure.com/myorg/anyteamproject/_git/tempgitrepo git push -u origin –all
(done with using git-tfs) Cloned the temporary Git repo to my local machine git-tfs clone https://user#dev.azure.com/myorg/anyteamproject/_git/tempgitrepo
(done ) Created an empty new folder “migrated” in the existing target TFVC repo (done with git-ft but from this step I am not sure it is a correct approach now) Cd into the directory that the code was cloned into, and run the configure command: git-tf configure https://dev.azure.com/myorg/ "$/mytargetteamproject/migrated" (here git-tf does not due to Basic Authentication issue as it is no longer supported. Using gif-tfs led to bootstrapping to the tenant we would like to copy from - to original )
Run the pull command to merge two repos does not work - git-tf pull leads to bootstrapping to the wrong tenant - git-tfs pull the steps below simply cannot be executed as the step 8 cannot be completed properly.
Run a basic git commit command git commit -a -m "merge commit"
Checkin to the TFVC repo git-tf checkin –deep --metadata
The question is - is there a way to move TVCS repo from one tenant to another TVCS tenant repo?
Finally, I managed - of cause not only me - to do migration.
Unfortunately, git-tfs could not be used as it works not as git-tf.
The main issue was Authorization step with using git-tf.
Using token name and token as user name and password accordingly helped a lot.
All the steps done can be seen below:
Install GIT, GIT-TF, Java
To clone source repository to local GIT
git-tf clone https://azerov:[source token]#dev.azure.com/OrganizationName "$/D365FOps_Learn02/Trunk" --deep
username: TestPatMigration (the name of the token)
password: [source token]
Create any remote GIT repository to push local cloned repo there
cd into cloned repo c:\users[curuser]\Trunk
git remote add origin
https://azerov:[git temporary target token]#dev.azure.com/OrganizationNameTarget/GitTemp02/_git/GitTemp02**
To push local cloned repo into temporary GIT repo
git push -u origin –-all
To clone temporary git repo to local machine
git clone https://azerov:[git temporary target token]#dev.azure.com/OrganizationNameTarget/GitTemp02/_git/GitTemp02
To configure the target TFVS Project to push local temporary GIT repo there
cd into c:\users\GitTemp2
git-tf configure https://azerov:[git temporary target token]#dev.azure.com/OrganizationNameTarget/ “$/D365FOps_learn02/Trunk”
git-tf pull
Username: PATMigration (the name of the target source token)
password: [git temporary target token]
git commit -a -m "merge commit"
git-tf checkin –-deep –-metadata
I have an android project in GitLab with multiple branches. I want to clone the repo in TFS with full history. I did not get any article which I clearly told about the process. Please suggest any way.
You can import your GitLab repository into the project on your TFS server.
Directly import the repository:
This will automatically create a new repository with the same name on TFS server, and import all the branches and history from the GitLab repository.
Import to an empty repository:
If you have created an empty repository into the project on your TFS server, you can see the "Import a repository" section on the page of this empty repository. Click the "Import" button to import your GitLab repository. This also will import all branches and history from the GitLab repository.
To view more details, you can see "Import a Git repo".
[UPDATE]
If your TFS server is TFS 2017 RTM or earlier, the "Import repository" feature is not supported on these older versions. You need to manually import the repository. See "Manually import a repo".
For example:
# Clone the source repo to a local folder
git clone --bare http://tfs2015:8080/tfs/DefaultCollection/BrightProj/_git/MyRepo
cd MyRepo.git
# Create the target repo on TFS server
# Push the local repository to the target repo
git push --mirror http://tfs2017:8080/tfs/DefaultCollection/BrightProj/_git/MyRepo
In our whole company we are the first one trying this.
We are trying to get the code from TFS into Azure DevOps.
Below is TFS details
TFS Server: companyTFS
TFS Project Collection: TechTeam.
TFS Project name: Main.
TFS Branch : Dev
Now I am trying to get code from TFS into Azure DevOps. We could have just copied the code from TFS folder into Azure DevOps folder but we do not want to lose the TFS history.
As described in below I installed Chocolatey and also installed gittfs.
https://blog.rsuter.com/migrate-a-tfs-repository-to-a-vsts-git-repository
When I give below command
git tfs clone http://companyTFS:8080/TechTeam/Main $/Main/Dev/Registration/FeeDetails . –ignore-branches –debug
I am getting below exception.
TF31002: Unable to connect to this Team Foundation Server: http://companyTFS:8080/TechTeam/Main.
Team Foundation Server Url: http://companyTFS:8080/TechTeam/Main.
Possible reasons for failure include:
- The name, port number, or protocol for the Team Foundation Server is incorrect.
- The Team Foundation Server is offline.
- The password has expired or is incorrect.
Technical information (for administrator):
The remote server returned an error: (404) Not Found.
The remote server returned an error: (404) Not Found.
I also tried this but did not work.
https://github.com/microsoft/azure-repos-vscode/issues/320#issuecomment-335573266
I am trying to find out whether my TFS server can do handshaking with external components.
I would be glad if someone can tell me what I am doing wrong.
At last after spending almost 4 days, I am able to move the code from TFS into Azure DevOps along with history. Please see below all the steps I did.
Install Chocolatey:
First we need to install Chocolatey. To make matters simple I created below two files in same folder.
FileName : installChocolatey.cmd
Content:
#echo off
SET DIR=%~dp0%
%systemroot%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& '%DIR%install.ps1' %*"
SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
FileName: install.ps1
Content: Copy paste the content from here https://chocolatey.org/install.ps1
Open command prompt in admin mode and ran installChocolatey.cmd to install Chocolatey.
In command prompt give choco -v to see whether it is installed correctly.
Install git tfs:
Next, we need to install git tfs tool in order to do that give below command in command prompt and follow the instructions.
choco install gittfs
In my case it installed to C:\Tools\gittfs.
Open Environment Variables and make sure you add below (in my case )to PATH variable.
C:\Tools\gittfs
In command prompt give git tfs -version to see what version it installed.
Move code from TFS to Azure DevOps:
Azure DevOps Project Name: Experiment
Azure DevOps Repo Name: MyRepo
Azure DevOps Repo Name: Master and DEV
First, I clone this repo to my local. Made sure that I have all remoted branches onto my local.
In my local created a new branch name called TestBranch and pushed it to remote. So now MyRepo has 3 branches and TestBranch is my local working branch.
In command prompt, I went to folder where I mapped Azure DevOps repo. I gave below command to get TFS code with history.
git tfs clone http://companyTFS:8080/TechTeam $/Main/Dev/Registration/FeeDetails . –debug
This will take sometime and after that you can see that TFS code is downloaded to that folder.
In same command prompt,
give below command to make sure what is your working branch
git branch
Below command will create a branch
git checkout -b TempBranch
For below command get url of your target Azure DevOps repo.
Below command will set your remote Azure DevOps Repo as Repo where you want to target
git remote add origin https://xxx#dev.azure.com/xxx/Experiment/_git/MyRepo
Below will create new branch called TempBranch in your target repo in ADO. Here in Experiment project and MyRepo repo
git push --set-upstream origin TempBranch
Now all your code and history from TFS made its way into Azure DevOps into your Repo. You can use PULL Request feature to merge into other branches and so on.
Now lets say you want your Azure DevOps code structure to be different.
Go to folder where you downloaded code/history from TFS and create folder structure or changes the way you want
Giive below command one by one.
git add .
To see all your changes give below command
git status
To commit all your changes in local
git commit -m "[commit message goes here]"
Command to push the changes from local to remote
git push
The code will be in Experiment project MyRepo repo TempBranch branch
we have an local DevOps Server 2019 with our old projects and I am able to clone this projects with git-tfs to local Git repositories. Everything is fine. After that I can push this repositories to our AzureDevOps Git repositories. Everything ok.
Now we have some projects and colleagues who want to use TFVC for these special projects. So my idea was to clone these projects from local TFS to Git and then use git-tfs rcheckin to push it to our AzureDevOps project.
But when I use "git-fts rcheckin --remote azuretfs" I get "error: latest TFS commit should be parent of commits being checked in"
When I use "git-tfs checin --remote azuretfs" all files are uploaded to the AzureDevOps project but without the history.
So can anyone describe what I have to do?
Note: I don't want to use the MigrationTool offered by Microsoft because of to many erros during validation the templates of work items etc. (we dont use it...)
For those who are looking for the same:
With the 'old' git tf tool (https://archive.codeplex.com/?p=gittf) you can migrate old TFVC project to Azure DevOps(TVFC).
If you want to migrate old TFVC projects to AzureDevOps(GIT) you should use git tfs (http://git-tfs.com/)
What you could try without guarantee of success...
Note: As I said, you will be able to migrate the history from one branch only.
Create the folder/project in TFVC where you want to put the source code.
Migrate this folder with git tfs clone (to have a git commit with the git-tfs metadata required to rcheckin)
Add the already migrated history repo (let's call it RepoWithHistory) as a local remote in this new repository (let's call it NewRepo). And git fetch
Clean metadata for only the commit coming from RepoWithHistory with something looking like: git filter-branch -f --msg-filter "sed 's/^git-tfs-id:.*$//g'" -- --all. But be careful to keep the metadata on the commits coming from NewRepo.
Use git replace --graft <sha1_of_first_commit_of_RepoWithHistory> <sha1_of_last_commit_of_NewRepo> to graft the 2 histories (the history must be on top of the one from the new one)
Use git rcheckin --no-merge to migrate the history to TFVC (that will be long...)
I hope it will help.
PS: perhaps you should try to do it on a small subset of commits to be able to verify it will works before doing it in the real TFVC project.
I have an account on bitbucket where two teams are present. Inside one team I have a project. Now I want to move that project into another team.
Can anyone tell me that it's possible to do so. If yes, please tell me the procedure.
Thanks..!!
Create a project with empty repo within the new team in Bitbucket.
Clone the original project locally (assuming "origin" for the remote name):
git clone <url>
In you local repo, add a new remote for the new project repo (assuming "neworigin" for the remote name) and fetch from it:
git remote add neworigin <url>
git fetch neworigin
Push everything from the original project (origin) to the new one (neworigin) with :
git push neworigin +refs/remotes/origin/\*:refs/heads/\*
git push --tags neworigin