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.
-
Are you using TFVC or Git? – Daniel Mann Sep 14 '18 at 15:54
7 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:
- 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.
- 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).
- 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.
So the local project will be imported into the TFVC repo in Azure devops.

- 402
- 1
- 7
- 16

- 36,876
- 5
- 61
- 74
-
4Isn't there an easier way with Git without using CLI that I don't understand? – Don Baechtel Sep 15 '18 at 16:08
-
3What is the URL for Azure Git repo if the project is in Visual Studio on my local machine? – Don Baechtel Sep 15 '18 at 16:14
-
4How come that is not an easier way to Import a Visual Studio 2017 solution into Azure DevOps with a single button push? If I have connected Visual Studio to my DevOps project, doesn't Visual Studio have all the information to do this Import? – Don Baechtel Sep 15 '18 at 16:16
-
@DonBaechtel The repo URL can be `https://account.visualstudio.com/project/_git/repo` or `https://account@dev.azure.comaccount/project/_git/repo`. And you can find the URL in the Azure DevOps project -> Repos Hub. – Marina Liu Sep 17 '18 at 08:08
-
1I had to use double quotes on the git commit command. With single quotes I got this error: git commit error: pathspec 'commit' did not match any file(s) known to git So I used this command that worked: git commit -m "initial commit" – Rich Apr 11 '19 at 15:22
-
Excellent answer. Wasted loads of time before I found this. Maybe worth adding a comment that you should add a .gitignore file to your folder BEFORE running these commands, otherwise you end up pushing loads of files you don't actually want in the repository – Avrohom Yisroel Jul 02 '20 at 19:39
-
@DonBaechtel Yes, of course, create a local git repo, then in the team explorer click home > sync. you will find three opts: push to GitHub, DevOps, or another remote server – AbuDawood Aug 10 '20 at 11:26
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.

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

- 1,474
- 2
- 17
- 36

- 655
- 8
- 11
Use git push --mirror
.
Warning: This will overwrite existing stuff on the remote repo. Use on an empty remote repo only.
- Create the remote repo in DevOps (if not done already).
- Create an intermediate, temporary local bare repo:
git clone --bare <path-to-local-repo>
cd <bare-repo-name>
git push --mirror <remote-url>
- Delete the intermediate repo:
cd .. && rm -rf <bare-repo-name
(This is Microsoft's recommended procedure.)

- 2,198
- 29
- 34
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.

- 83
- 1
- 10
You could also perhaps try to: Clone the Repository to your machine. Add a .gitignore if not already present. Right click the .gitignore file. Select 'Open Containing Folder'. Delete .vs folder if present. Open another file explorer and go to your existing project you would like to import. You should be at the level where you see .vs folder and other folders. Copy all and paste to the same folder the .gitignore is in. Run your application from the new location and make sure it runs the same as where it was copied from. And push it back up to the Repository.

- 36
- 4
For Git
For manual import you can use commands like mentioned here
For TFVC
Note: The images are obtained from the old UI. Now the AzureDevOps UI is changed,but the process is quite similar

- 9,638
- 8
- 60
- 103
-
I do not see a Code button on my Azure DevOps. Where is it? How do I display the Code button? – Don Baechtel Sep 15 '18 at 16:07
-
Where do I get the Clone URL is the project is in Visual Studio on my local PC? – Don Baechtel Sep 15 '18 at 16:12
-
@DonBaechtel please see my **update 1** in my answer. The code will be available inside the `Azure Repos`, within this you can get all the feature to use – Jayendran Sep 15 '18 at 16:39
-
@DonBaechtel Is there any update on my answer above ? If you found it useful then please accept/upvote it, so that it can help other community members – Jayendran Sep 18 '18 at 12:26
-
1The answers were not helpful. The pictures did not match the Azure DevOps. There was no Code button. I do not know the Clone URL that is being requested. I could not follow the steps provided. – Don Baechtel Sep 18 '18 at 21:27
-
@DonBaechtel Did you see my *update1 * in the above answer ? I've provided the way to find the code button in new Azure DevOps UI – Jayendran Sep 19 '18 at 01:51
-
-
@DonBaechtel The code button is changed into files in the new UI. I've edited my image above. Look at that. Under the file menu,you will find all the options – Jayendran Sep 20 '18 at 02:50
-
The Import a GIT Repository requires a Clone URL. Where do I get this Clone URL? The Git repository is on my local PC. I am not sure what directory or how to create the Clone URL. – Don Baechtel Sep 21 '18 at 03:24
-
@DonBaechtel In the image I highlighted the clone URL (yellow color). You just copy that and do the command like `git clone
` then copy all the files(from your local git repo) and paste it in the new cloned directory, then push it – Jayendran Sep 21 '18 at 03:41 -
It appears that Azure Repo wants me to provide a Clone URL. How do I get this Clone URL? – Don Baechtel Sep 22 '18 at 12:04
-
@DonBaechtel It is located on the top right corner.If you press the `clone` button you get the link to your repo, it typically would be like `https://
.visualstudio.com/ – Jayendran Sep 22 '18 at 12:22/_git/ ` -