简体   繁体   English

如何将现有的 Visual Studio 2019 项目添加到 git 存储库?

[英]How can i add an existing visual studio 2019 project to a git repo?

I have a boilerplate project named 'XYZ' structured like this:我有一个名为“XYZ”的样板项目,其结构如下:

-XYZ.Domain
-XYZ.CrossCutting
-XYZ.Application
-XYZ.Backend
-XYZ.Infrastructure

I want to do these steps:我想做这些步骤:

  1. Rename everything to ABC:将所有内容重命名为 ABC:

     -ABC.Domain -ABC.CrossCutting -ABC.Application -ABC.Backend -ABC.Infrastructure
  2. Add it to a git repository将其添加到 git 存储库

  3. Push everything.推动一切。

How can I accomplish this using visual studio 2019?如何使用 Visual Studio 2019 完成此任务?

From the solution explorer select your solution and pick Create Git Repository (requires the new Git Tools to be enabled):从解决方案资源管理器 select 中选择您的解决方案并选择创建 Git 存储库(需要启用新的 Git 工具):

在此处输入图像描述

Fill in the wizard that pops up:填写弹出的向导:

在此处输入图像描述

And you have a reporitory.而且你有一个存储库。 If you don't have a .gitignore file yet, I'd pick "local repo", as using one of the other options will immediately commit & push.如果您还没有.gitignore文件,我会选择“本地仓库”,因为使用其他选项之一将立即提交和推送。 Then add the ignore file and exclude any items you don't wish to push before pushing to a git service:然后在推送到 git 服务之前添加忽略文件并排除您不想推送的任何项目:

在此处输入图像描述

You can do your renames before or after.您可以在之前或之后进行重命名。 Which would be a separate and unrelated question to how to initialize the git repo.对于如何初始化 git 存储库,这将是一个单独且不相关的问题。

Renaming the project files can easily be done in the solution explorer.重命名项目文件可以在解决方案资源管理器中轻松完成。 Renaming the folder containing each project is trickier.重命名包含每个项目的文件夹比较棘手。 You need:你需要:

  • Rename the project in Solution explorer在解决方案资源管理器中重命名项目
  • Save all files ctrl + shift + s保存所有文件ctrl + shift + s
  • Remove the renamed project from your solution从您的解决方案中删除重命名的项目
  • Rename the project folder in Windows Explorer.在 Windows Explorer 中重命名项目文件夹。
  • Use the Add existing project option in the solution explorer to add the project file in its new location:使用解决方案资源管理器中的添加现有项目选项将项目文件添加到其新位置:

在此处输入图像描述

  1. It's cleaner to re-name prior to adding a Git repo, but it can be done after.在添加 Git 存储库之前重命名更简洁,但可以在之后完成。
  2. To push to a Git service without additional tools simply create a local repo by right-clicking your solution and select Create Git Repository.要在没有其他工具的情况下推送到 Git 服务,只需通过右键单击您的解决方案和 select 创建 Git 存储库来创建本地存储库。 Next, in Team Explorer click the sync option...接下来,在团队资源管理器中单击同步选项... 在此处输入图像描述

Then, it will ask you to Push to a Git service.然后,它会要求您推送到 Git 服务。 在此处输入图像描述

Follow the prompts to sign in to the service of your choice and choose the project/repo.按照提示登录您选择的服务并选择项目/存储库。

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

相关问题 如何在 visual studio 中将项目添加到源代码管理(现有 GIT 远程仓库)? - How to add a project to source control (existing GIT remote repo) in visual studio? 如何在使用 Visual Studio 的项目中将 Git 存储库链接到现有 Git 存储库 - How do you link a Git Repo to an Existing Git Repo in a project using Visual Studio 如何在不破坏 Visual Studio 的情况下恢复项目的 Git 存储库? - How can I revert my project's Git repo without breaking Visual Studio? 使用团队资源管理器中的 Git 存储库将现有项目添加到 Visual Studio 2017 解决方案中的源代码管理 - Add existing project to source control in Visual Studio 2017 solution using Git repo in Team Explorer 如何将现有的Visual Studio项目添加到空的git存储库 - How to add existing visual studio project to empty git repository Visual Studio 2019-如何添加Git远程 - Visual Studio 2019 - How to add Git remote 如何将eclipse项目添加到现有的git仓库? - How to add eclipse project to existing git repo? Visual Studio 中的 Git - 添加现有项目? - Git in Visual Studio - add existing project? 将 Visual Studio 项目添加到现有的 git 存储库 - Add a visual studio project to an existing git repository 如何通过Android Studio将本地git repo提交到github上的现有远程仓库? - How can I commit a local git repo to existing remote repo on github through Android Studio?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM