Home > Blockchain >  Adding an existing Visual Studio 2022 Solution to a new Azure Git Repository
Adding an existing Visual Studio 2022 Solution to a new Azure Git Repository

Time:08-07

I'm getting really confused about the process. This is partly because I'm moving from SVN to Git, I think. I've created a Solution with 3 projects in. I've also created a new matching project in Azure Dev ops. I think from my reading that the normal setup is to have git repo on the local machine (for more frequent local checkins) and then a less regular push to a repo on the azure server. I did manage to set up another project where I setup it up on Azure first and then cloned it onto my local machine as new, so this works really well for that (the local git commits followed by the nightly azure ones). However in this situation, I already have the local code base and now need to setup the Azure repo (other way around)

So this is where I'm getting really confused. I've set up a new azure project which auto sets up a repo of the same name. There's a few routes lead to associating it with a new/existing repo, but they all seem to lead to the same sticking point which seems later down the line. Here's one example, clicking "Add to Source Control" in the status bar. Bring up this window:

enter image description here

Says "Created and pushed repository to ..." just fine. The problem is the next step. If I click on Git Changes, all I see is:

enter image description here

Meaning I can't check code in or out. If I go to Team Explorer, I see:

enter image description here

And if I click Clone this Repository, I get:

enter image description here

Which autogenerates a new folder in my local source code folder called "Infoz2". This essentially starts a new Solution/Project and detaches from my original code.

It's all totally unintuitive. To you guys who work with this every day I'm sure it's a no brainer, but for someone trying to understand it prima facie, it just doesn't make sense.

So how can I achieve my original goal?

And on an aside, does it involve having a separate git code folder (so you'd have local original code folder; local versioned git code folder and then remote versioned azure code folder) or is the git code somehow subsumed into the visual studio solution folder structure?

============ EDIT: Given few answers, I sought to simplify the scenario to using Github only. Same issues though. I made a short video (link below). I also ensured I cleaned out the project folder beforehand of any git remnants. You'll see, despite repo creation, no files are pushed, and there's no facility to push/sync files in the git tab. Driving me nuts, this. Vid:

Add remote menu

Add a remote setting

Enter the name of the remote (by convention it's 'origin') and your repo url:

Add one remote

Your local repo now knows the remote repo and you will be able to push (or force push if the remote repo has been created with a commit for the README.md).

CodePudding user response:

So it turned out it was something quite obscure - maybe even a bug? I had to change to ownership of the Solution folder to my Username rather than System. This then allowed the pushing of files. The post that I read this in (I've lost the link) also mentioned that Starting Visual Studio as Administrator also circumnavigates this (which makes sense given the privileges issue) - so I just set the shortcut to boot as admin. It's a shame nothing shows in the output window to show any errors. Anyways, this is how to solve the problem.

  • Related