Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git best-practices with Visual Studio projects

I want to use Git for some personal projects I work on. I'm new to git and don't know how to start...

Should I first create the project (say an ASP.NET MVC application) in Visual Studio and then turn the folder that is created into a repository, or should I create a repository first and then create the project inside that folder?

Also, are there any best-practises for how to structure the folders inside the "repository root folder"?

These are my two questions right now, but any pointers to articles etc for best-practises using Git and Visual Studio are welcome!

like image 986
haagel Avatar asked Jan 06 '13 11:01

haagel


People also ask

Can you use Git with Visual Studio?

Start with Git & GitHub in Visual Studio Or, you can work locally with no provider at all. To get started using Git with Visual Studio: If you have a Git repo hosted on a Git provider like GitHub, clone the repository to your local machine. Otherwise, easily create a new Git repository and add your code.

What should I not put in Git?

You shouldn't store credentials like usernames, passwords, API keys and API secrets. If someone else steals your credentials, they can do nasty things with it.


1 Answers

Git repositories are so lightweight that it doesn't really matter whether you create the project and then create the repo or create the repo and add the folders. You will anyway be doing a git add and git commit after the folders have been created.

But, for me, I usually create the project from VS and restructure the folders so that at the root there is the src folder and the .sln and project files are within the src folder. VS would typically create the root folder with the project name which I rename to src. Then I create the repo, add the standard .gitignore and .gitattributes and commit the repo.

See my preferred structure here: https://github.com/manojlds/cmd

Of course, you can have whatever structure you want.

like image 109
manojlds Avatar answered Oct 22 '22 15:10

manojlds