How to Import project code from local machine to Azure Repos?

Viewed 69487

I have existing code on local PC in Visual Studio that I want to Import to the Azure Repos project. I have already created the Project in Azure DevOps. I have used Team Explorer in VS 2017 to Connect to my DevOps project. I don't know how to do the initial Import.

6 Answers

If you are using Git repo in Azure Devops, please refer below commands to import projects to Azure Git repo:

#In the local directory for the root of the project 
git init 
git remote add origin <URL for Azure Git repo> 
git add .
git status   
git commit -m "initial commit"  
git push -u origin master 

Then the project in the local machine will be managed in Azure Git repo.

Note: if the local project has already been managed in a local git repo, then you can skip git init command.

If you are using TFVC repo in Azure Devops, please refer below steps to import the local project to Azure TFVC repo:

  1. connect TFVC with VS

In VS -> team explorer -> Manage Connections -> Add an account -> enter the email address and password for sign in Azure Devops -> select the TFVC repo -> Connect.

enter image description here enter image description here

  1. map TFVC repo in a local directory.

Click Map & Get button to map the TFVC repo and download the files in the specified directory (as C:\Users\Administrator\Source\Workspaces\Git2 in below example).

enter image description here

  1. copy the local project to the mapped directory and checkin changes

Copy your project in the TFVC repo mapped directory -> team explorer -> Source Control Explorer -> click Add items to folder icon -> select all the project files you copied in the mapped directory -> Finish -> Team Explorer -> Pending changes -> checkin the changes.

enter image description here

So the local project will be imported into the TFVC repo in Azure devops.

Follow below step

Step 1 - Login Azure Devops using microsoft account.

Step 2 - In home page click create project,Provide the project name visibility status.

Step 3 - Now Your project was created then it's redirect to dashboard then select repos from the left menu.

Step 4 - Copy the URL.

Step 5 - Now go to visual studio team explore from local git repositories click Add option.

Step 6 - Create new repo from drive then local path and paste the URL path in second option then click clone.

Step 7 - Enter your Azure DevOps credentials for login.

Step 8 - It will publish your code on the master branch.

Step 9 - On successfully publish the changes your code will be displayed in the Azure Repos file section.

  1. Right click on the main solution ▶︎ Create git repository…
  2. From other section ▶︎ Existing remote
  3. Paste «URL of Azure Git repo» in Remote URL field
  4. Click on Create and push
  5. Wait for the process to complete. You can follow the process by clicking on ready icon on left bottom of window.
  6. If it shows successful, it’s ready.

Good luck with that...

Use git push --mirror.

Warning: This will overwrite existing stuff on the remote repo. Use on an empty remote repo only.

  1. Create the remote repo in DevOps (if not done already).
  2. Create an intermediate, temporary local bare repo: git clone --bare <path-to-local-repo>
  3. cd <bare-repo-name>
  4. git push --mirror <remote-url>
  5. Delete the intermediate repo: cd .. && rm -rf <bare-repo-name

(This is Microsoft's recommended procedure.)

It is pretty easy to turn on git in Visual studio but when you set up the remotes under git configuration of Visual studio, you may get an error message 'invalid name'. Then you need to enter 'origin' as the name and the fetch URL of your initial empty project of DevOps into the fetch box in Visual Studio. I am sure it could help some to add their existing projects to azure DevOps.

For Git

enter image description here

enter image description here

enter image description here

For manual import you can use commands like mentioned here

For TFVC

Reference here

Update 1: enter image description here

Note: The images are obtained from the old UI. Now the AzureDevOps UI is changed,but the process is quite similar

Related