Search code examples
azure-devopsdevopsvisual-studio-2022

Push an existing project into a new Azure DevOps repository in Visual Studio 2022


I have an existing Visual Studio project with existing code
and a newly created Azure DevOps (git) project with an empty repository.

Now from Visual Studio 2022 I want to push my project into the DevOps repository.

This should be a very common problem, I guess.

However, when I use "Create Git Repository", it won't let me create the repository with the same name, since it already exists, because DevOps automatically creates a repository with the same name for a new project:

enter image description here

So I don't really need to create a new repository, but just connect to the existing one, so I can push the project there. But I haven't found a good way to do so.

My workaround so far was:
- Create the new DevOps project "MyApp"
- Create a second repository "Dummy" there, because there must be at least one
- Delete the "MyApp" repository
- Create a new "MyApp" repository from Visual Studio
- Delete the "Dummy" repository

That works, but it's obviously stupid. There should be a straightforward, obvious way to do it.

I'm really confused I couldn't find a good answer online, as I believe this must be the second most common use case (after creating both a new DevOps project and a new VS project at the same time). Maybe I'm just terribly bad at googling.


Solution

  • In the image, under Other you have Existing Remote. You can use this and add the url to the repo that was created by default