DDiVita
DDiVita

Reputation: 4265

GitHub repository and local development structures

First, all of our projects are .Net C# projects.

I need some advise on the best way to setup my local and repository structures.

We have one main project that serves as the core library that is used by all of our projects. I don't necessarily want to have one repository with multiple projects, but I do want my other projects to have access to the main library's project. I'd like to have each project in their own repository for organizational purposes.

I have an idea of what I should do on my local system to make this happen, but I wanted to get the communities opinions before I start setting up my projects.

Update

So similar to what Bradley suggested I went with a structure similar to this:

All Projects Folder
     Core Project
     Another Project
     Yet another Project

Using GitHub for Windows you can use the Clone To feature to place your local repositories in the main projects folder. So, in this example, I would select the Remote Repository from GitHub for Windows, right click on the remote repository you want to clone and select the Clone To. I would select the "All Projects Folder" to place my code in. This will create the folder and project structure for you. Then, other projects can reference each other by using the relative paths within that structure. I found that also using Git Source Provider for Visual Studio 2012 helps with seeing all pending changes between projects.

Upvotes: 0

Views: 601

Answers (2)

Bradley Grainger
Bradley Grainger

Reputation: 28182

Assuming you are going to divide your code up into multiple repositories, one way to include one repository as a dependency of another is to use git submodules.

I've personally found submodules a bit of a pain to use on a day-to-day basis. (E.g., git checkout doesn't update submodules automatically when switching branches; too often, developers have inadvertently rolled back a submodule by forgetting to git submodule update before adding everything, etc.)

As a result, we prefer a "convention over configuration" approach, and simply clone all necessary repositories as siblings of each other. When making changes to two repos, you simply commit to and push both repos, and assume that other developers are tracking the master branch in both repos and will pull both at once.

It's easy to write a bash script or batch file that will set this up on a new machine, or will update all the repos at once on an existing machine.

For more detailed examples, see my Sharing Code across Projects blog post.

Upvotes: 1

Darin Dimitrov
Darin Dimitrov

Reputation: 1038930

You could create and publish a NuGet package out of this main project and then have the other projects simply install this NuGet. This way other people could also consume this common NuGet in their applications.

Upvotes: 1

Related Questions