简体   繁体   English

将现有的 Visual Studio 2022 解决方案添加到新的 Azure Git 存储库

[英]Adding an existing Visual Studio 2022 Solution to a new Azure Git Repository

I'm getting really confused about the process.我对这个过程感到非常困惑。 This is partly because I'm moving from SVN to Git, I think.我想这部分是因为我正在从 SVN 转移到 Git。 I've created a Solution with 3 projects in. I've also created a new matching project in Azure Dev ops.我创建了一个包含 3 个项目的解决方案。我还在 Azure 开发操作中创建了一个新的匹配项目。 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.我认为从我的阅读来看,正常的设置是在本地机器上安装 git 存储库(用于更频繁的本地签入),然后不定期推送到 azure 服务器上的存储库。 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).我确实设法设置了另一个项目,我首先在 Azure 上设置它,然后将它作为新的克隆到我的本地机器上,所以这非常有效(本地 git 提交,然后是每晚的 ZCF04A02E37B774FC317A 提交) However in this situation, I already have the local code base and now need to setup the Azure repo (other way around)但是在这种情况下,我已经有了本地代码库,现在需要设置 Azure 存储库(其他方式)

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.我已经设置了一个新的 azure 项目,它会自动设置一个同名的存储库。 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:调出这个 window:

在此处输入图像描述

Says "Created and pushed repository to..." just fine.说“创建并推送存储库到...”就好了。 The problem is the next step.问题是下一步。 If I click on Git Changes, all I see is:如果我点击 Git Changes,我看到的只是:

在此处输入图像描述

Meaning I can't check code in or out.这意味着我无法签入或签出代码。 If I go to Team Explorer, I see:如果我 go 到 Team Explorer,我会看到:

在此处输入图像描述

And if I click Clone this Repository, I get:如果我单击克隆此存储库,我会得到:

在此处输入图像描述

Which autogenerates a new folder in my local source code folder called "Infoz2".它会在我的本地源代码文件夹中自动生成一个名为“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? 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文件夹结构?

============ EDIT: Given few answers, I sought to simplify the scenario to using Github only. ============ 编辑:给出几个答案,我试图将场景简化为仅使用 Github。 Same issues though.不过同样的问题。 I made a short video (link below).我制作了一个简短的视频(下面的链接)。 I also ensured I cleaned out the project folder beforehand of any git remnants.我还确保我事先清理了项目文件夹中的任何 git 残留物。 You'll see, despite repo creation, no files are pushed, and there's no facility to push/sync files in the git tab.您会看到,尽管创建了存储库,但没有推送任何文件,并且 git 选项卡中没有推送/同步文件的工具。 Driving me nuts, this.把我逼疯了,这个。 Vid:视频:

YoutTube优管

From what I understand, you already have your local git repository with some history and want to push it.据我了解,您已经拥有具有一些历史记录的本地 git 存储库,并且想要推送它。

If the ADO remote git repository already exists and you want to push to it, you must get the remote git repository url and add a remote:如果 ADO 远程 git 存储库已经存在并且您想要推送到它,您必须获取远程 git 存储库 url 并添加远程:

添加远程菜单

添加远程设置

Enter the name of the remote (by convention it's 'origin') and your repo url:输入遥控器的名称(按照惯例它是'origin')和你的repo url:

添加一个遥控器

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).您的本地存储库现在知道远程存储库,您将能够推送(或者如果远程存储库已使用 README.md 的提交创建,则强制推送)。

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.我在其中读到的帖子(我丢失了链接)还提到,以管理员身份启动 Visual Studio 也会绕过这个(考虑到权限问题,这是有道理的) - 所以我只是将快捷方式设置为以管理员身份启动。 It's a shame nothing shows in the output window to show any errors.遗憾的是,output window 中没有显示任何错误。 Anyways, this is how to solve the problem.无论如何,这是解决问题的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM