Migrate project repo from TFS to DevOps

  1. Read the page below:

How-to migrate project from TFVC to Git by using Git-TFS

2. Run PowerShell as Administrator

3. Create a folder on your pc to add projects.

First, go to C:\ with the command below:

cd\

and after, create your default folder.

4. Go to TFS and find your project.

NOTE: It’s important that your project have branches

5. In your PowerShell, create a new folder with the name of the project that will be migrated.

6. Create a folder for each branch

7. Enter the folder of the branch to be migrated. For example if we want to do Git TFS Clone on Main, we should enter the Main folder and run the command in Step 9

cd Main

 

8. Go to DevOps and create a new repository with the name of your project.

NOTE: Don't add a README

 

9. Execute the command below, changing the data referring to your project and the command is run in the appropriate folder

git tfs clone http://tfsprod:8080/tfs/CivAv/ $/CADLIS-SILDAC/Main C:\devops\migration\CADLIS-SILDAC\Main

$/CADLIS-SILDAC/Main - the path of your branch in the project's TFS

C:\devops\migration\CADLIS-SILDAC\Main - the path created in your pc

*This step may take a while, as the entire project with the history is being copied.

 

10. Copy the command on DevOps and run it in PowerShell

 

11. Add a branch

 

12. Push to DevOps

 

If above steps fail to copy over any/latest files, please follow the instructions below:

  • Go to TFS and in a branch select Download as Zip

  • Extract the files in your local machine

  • Copy all files in your branch folder via Windows Explorer, still keep .git folder which was created by previous “gif tfs clone” command

  • Go to PowerShell and execute the commands

Will show the list of files being copied in the PowerShell screen

  • Copy the commit ID in the first row below the command

     

  • Execute the command with the commit ID copied (the commit ID besides your name only)

     

  • Push to DevOps again

     

    If there is any error like ‘origin does not appear to be a git repository', i.e we need to add an origin before to do the git push command, please see the ‘git remote add origin..’ section

 

13. Update the information about the new repository in Confluence. Go to the project page and add 2 new rows. See below:

 

**Notes: If the repo has a .NET version as well as the regular version, setting up the names as the following is recommended:

FINAL STEP: Add .gitignore to the source folder.
File found here: https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

Since the dev branch cannot be updated directly, you will need to add the file in a feature branch.

  1. Open VS2019

  2. Clone/open the project you are working on

  3. Create a new feature branch from the remote dev branch

    • Naming convention: feature/pbinumber-gitignore

  4. Ensure you are on this new branch, then in the top menu, choose Git → Settings → Source Control → Git Repository Settings → Click to add an Ignore file → Click OK

  5. Open Git Changes, add your commit message, then commit and push

  6. Create the pull request, from your feature branch to the dev branch

  7. After the pull request is approved, complete it to merge the changes into dev