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
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
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.
Environment: Visual Studio 2017, TFS project set at visual studio online.
I am working on a community project. The source code is checked into TFS project using the free account provided by visual studio online.
I now need to enable git on this project such that others can use from other projects.
On TFS online, I see a way to create a new GIT-based project but I don't see any option to enable GIT on an existing TFS project. I remember to have used this option long time ago. Wondering where I can find this switch. Or, is there any easy way to migrate existing code to GIT. Regards.
You can use Import repository to import the Git repository from TFVC.
From the repo drop-down, select Import repository.
Select TFVC from the Source type dropdown
Type the path to the repository / branch / folder that you want to
import to the Git repository. For example,
$/0522TFVCScrum/BuildProcessTemplates
If you want to migrate history from the TFVC repository, click
Migrate history and select the number of days. You can migrate up to
180 days of history starting from the most recent changeset. A link
to the TFVC repository is added in the commit message of the 1st
changeset that is migrated to Git. This makes it easy to find older
history when needed.
Give a name to the new Git repository and click Import. Depending on
the size of the import, your Git repository would be ready in a few
minutes.
Refer to this article for details: Import repositories from TFVC to Git
Hover over the Code tab, click "Manage Repositories", then click the "New Repository" button.
I am trying to migrate Source code from TFS to VSTS. I tried git-tf command to migrate and was able to migrate successfully but i am not able to migrate the history. Can someone guide me on what i am doing wrong. Please note i am not migrating to GITVC but migrating to TFVC in Visual studio from On premise TFS server.
Steps are ...
git-tf clone http://onprimisetfsurl/ $/project project
git-tf clone http://Visualstudiotfvcurl/ $project project1
git pull project1 into project
git-tf checkin --deep
Look at OpsHub https://visualstudiogallery.msdn.microsoft.com/28a90a17-d00c-4660-b7ae-42d58315ccf2 since that is the one that was recommended by the VSTS manager https://blogs.msdn.microsoft.com/bharry/2014/05/14/migrating-on-premises-tfs-to-vs-online/
https://www.visualstudio.com/en-us/articles/adopting-vsts also covers other tools if that doesn't work for you.
Add "--deep" when you perform git-tf clone:
git-tf clone http://onprimisetfsurl/ $/project --deep
Add my steps for your reference:
git-tf clone http://tfsurl $/tfsproject --deep
Create a project "vstsproject" in VSTS.
Delete the "BuildProcessTemplates" folder in the vstsproject from web portal.
Create a new folder for vstsproject on local machine.
Run "git init" to set this folder to a git repository.
Pull the changes in tfsproject into the new created repo.
Run "git log" to make sure the history is correct.
git-tf configure https://vstsurl $/vstsproject --deep
git-tf checkin --deep