Move code INTO Azure DevOps Repo FROM TFS WITHOUT losing TFS HISTORY - tfs

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

Related

Visual Studio 2019 XAML queue build to TFS 2015 failing

The last developer had been deploying our Intranet MVC project from VS2019 for years, using a method of XAML queue build up to TFS2015.
However after a recent VS update to 16.10.3 (from 16.1.3) - the queue build is now failing (see attached pic). It can't find all the config files (even though I can see them in the solution explorer).
I'm yet to determine if it was the VS update that killed it, or some other MS monthly patching (possibly on the TFS server itself).
As I'm very inexperienced in .NET MVC coding (in fact in VS), can anyone spot an obvious reason this is failing?
Traditionally the VS queue build function would complete in <1min, then the zipped up package could be located on the TFS\drops folder, and imported into IIS on the web server.
I'm in the process of restoring the VM to a point prior to the VS update (~65 days ago), and to a time when the Intranet solution was last published successfully.
Method to copy local code to Devops:
http://raaviblog.com/how-to-push-project-code-from-local-machine-into-azure-devops-git-repo/
1. git init
2. git remote add origin <replace the URL of Azure Git Repo copied earlier>
*if you get an error "fatal: remote origin already exists" - you can run:
git remote set-url origin
.…then continue to step 3. This alternative command replaces Step 2.
3. git add .
4. git commit -m “New project added”
5. git push -u origin master

Azure DevOps - Moving TVCS Repo from one tenant to another - 2021

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

Gitlab to TFS migration of Android project

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

Clone GIT to TFS (AzureDevOps) with git-tfs

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.

Integrate crucible with tfs

I use TFS with Jira to managment my team tasks.
I want to integrate a Code Review tool at development process.
When i try to use crucible i reveal that it not support TFS.
I want to know if , there is a good and credible solution for this ,to enable me use crucible with TFS.
additional , if there are another suggests for code reiview tool for VS and JIRA.
Thank!
Some time ago we decided to run Crucible on our project. Our project uses TFS 2012. We use one branch in TFS called 'dev' as a trunk, i.e. branch where developers make commits and where raw code located. Second branch where release code located called 'main'
Our workflow for peer review was:
Make some changes and shelve code
Send email to reviewer
Reviewer doing review in some custom tool and send email with notification that he is done
Commit code into 'dev' branch on TFS
Wait while build-server makes successful build
Commit to 'main' branch where production code resides
Our goal was to improve step 2 and 3. Crucible is great tool, but it doesn't support TFS out of the box, thus we decided to use some TFS bridge. Actually, there are two main options either using tfs->svn or tfs->git. Finally, we decided to use tfs->git bridge, because creating branches in git extremely cheap and it might have been helpful (it did), because we was thinking use branches in git for out shelvesets in TFS. Finally we made our mind to use git.
So far I know only 2 options to convert TFS into git:
git tf - this one works on Linux and recommended by Microsoft
git tfs - this one works only under Windows, but we choose this one, because of large set of commands
We need to convert TFS branch into Git repo and maintain our git repository in fresh state. We don't work with git to push new changes back into TFS, we need git repo only for Crucible.
There are steps we made to achieve the goal:
1. Firstly, we cloned our TFS "dev" branch into "dev" repo. We needed only this one branch, and we haven't any back merges from "main" branch. We have tried to do this with clone command, but without any luck:
git tfs clone http://tfs:8080/tfs/DefaultCollection $/SOME_PATH/dev
This command cloning full history from TFS, but it seems our TFS branch quite large and at some time git-tfs crashed with System.OutOfMemoryException exception. Another time, we failed with exception that max limit of path was exceeded, we found workaround by mapping workspace dir into as short path as possible as follows:
git config --global git-tfs.workspace-dir e:\ws
When we failed with clone command, we went to use quick-clone command. This one cloning starting from any time in history, from any changeset.
git tfs quick-clone -c545532 http://tfs:8080/tfs/DefaultCollection $/SOME_PATH/dev
Option -c545532 here is the number of changeset to starting copying from. Once per year we update all our source files with new header, thus we just to copy from beginning of current year. In that way we should have all necessary history to make branches from shelvesets.
If you hadn't used -c argument here, you would have haven't any history at all, because quick-clone copies just history if you asking for it.
Once repository was cloned, we had written "script" and put it into task scheduler to run every 5 min. What script is doing is just checking for new commits in TFS and creates new branches on our git repository. Again, we use git-tfs here. To get all new commits we call pull command:
git tfs pull
To unshelve TFS shelveset into particular git branch we use unshelve command:
git tfs unshelve -user=TFSDOMAIN\Username "Shelveset Name Here" Branch_Shelveset_Name_Here
This last command creates branch 'Branch_Shelveset_Name_Here' in git from shelveset 'Shelveset Name Here' in TFS. A shelveset's name can contains spaces and some escape chars, so our "script" clean up such cases. As I said, creating branches very cheap on git, thus we haven't any problems with this. If something was pushed into git repo we call crucible API to refresh it.
BTW: To make git repo visible in network I just installed SCM-Server. Crucible was installed and configured to use our domain username/password, thus we get email notification as well. As result we drastically improved step 2 and 3 from our workflow and it works for few months and we are happy with it.
Our workflow became:
Make some changes and shelve code
Wait for our shelveset in crucible (about 6-8 min), create review
Reviewer doing review in crucible
Commit code into 'dev' branch on TFS
Wait while build-server makes successful build
Commit to 'main' branch where production code resides
While working with this I noticed few issues:
Issue1: If you added new file into project and shelved it, you would not see it in git repo, because git-tfs can't find parent commit for it. I'm not sure is it bug of this tool or not, but simplest workaround for this, is having at least one file in shelveset with existing parent. For example, you have added 2 new files and want to send it for review. Instead of creating shelveset with these files, just touch any file which already in git repo (make it pending in Visual Studio), finally you will be able create shelveset with three files (2 new files [add] and 1 for edit [edit]). In that case everything works and git-tfs can unshelve TFS' shelveset into git branch., i.e. we can see it in crucible.
Issue2: One day our HEAD in git repo became detached from "master" branch. Once that happened crucible didn't see new changesets. I have fixed it with command:
git rebase HEAD master
I have created picture how this everything works on our project, may be it could be helpful:
You can integrate Mira and TFS with TaskTop and then use the code review tools built into Visual Studio.
Code Review added in Visual Studio 2012
TaskTop integration with TFS & Jira
These I think are your best options.

Resources