简体   繁体   中英

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.Domain
-XYZ.CrossCutting
-XYZ.Application
-XYZ.Backend
-XYZ.Infrastructure

I want to do these steps:

  1. Rename everything to ABC:

     -ABC.Domain -ABC.CrossCutting -ABC.Application -ABC.Backend -ABC.Infrastructure
  2. Add it to a git repository

  3. Push everything.

How can I accomplish this using visual studio 2019?

From the solution explorer select your solution and pick Create Git Repository (requires the new Git Tools to be enabled):

在此处输入图像描述

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. Then add the ignore file and exclude any items you don't wish to push before pushing to a git service:

在此处输入图像描述

You can do your renames before or after. Which would be a separate and unrelated question to how to initialize the git repo.

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
  • Remove the renamed project from your solution
  • Rename the project folder in 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.
  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. Next, in Team Explorer click the sync option... 在此处输入图像描述

Then, it will ask you to Push to a Git service. 在此处输入图像描述

Follow the prompts to sign in to the service of your choice and choose the project/repo.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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