Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
321 views
in Technique[技术] by (71.8m points)

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

enter image description here

Fill in the wizard that pops up:

enter image description here

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:

enter image description here

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:

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...