ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

More Git

(1/2) > >>

I have a lot of projects for personal use- development and non-development work (writing and such).  I've tried multiple projects in one repo, and one repo per project.  I've seen a lot of different arguments for either, and a lot of them on both sides have referred to my pain points - shared libraries, repo overload, etc.  I was also looking at this stackoverflow question, and it brought up more questions than answers.

I was just wondering as a lot of people use Git around here, what are your personal preferences and why?  And no, I'm not looking at this point to transfer to another VCS.  I settled on Git a while ago, so that decision is made.

My answer probably won't be of much help to you, since I primarily use Mercurial (Hg) and have only dabbled with Git.

I've looked into similar options for Hg and found that it's too much of a hassle having to deal with subrepos and getting them configured correctly. So I just end up with lots of copies of the same kinds of files (libraries, or general purpose scripts that I reuse over many different projects), and I have to try to remember which project I was working on most recently when I updated shared general purpose script if I forgot to update it in my standard directory where I store my scripted tools.

It's a hassle, but from my research in Hg, it's less of a hassle doing it this way than trying to deal with subrepos.

That said, I think Git handles subrepos (aka submodules) differently and perhaps in a way that makes more sense and is easier to use than Mercurial does. The linked StackOverflow question/answer seems to suggest that that is the case.

Anyway, sorry for my mostly non-helpful response. Hopefully someone who is a lot more familiar with Git can provide you some real assistance. :Thmbsup:

For my own work, I aim to have one repo per project. Here are some reasons:

* Unless the projects are very strongly connected, separate repos means you have a clear development history for each.
* Git usually means branching -- and branching all projects to work on a change in one of them is silly (even if it's cheap)
* If one of the projects becomes useful to other people, it will be easier if they can clone that alone
* If you use submodules to include a library, you know the exact version (commit) you are using. If you just include the source in multiple project repos you have no idea which changes you may have made in each of them (like Deozaan, I sometimes end up there :-[)
* If you do not use submodules, it can be nice to have the development of the library in a repo of it's own for the three first reasons above
But it will depend on the project. Something like chapters of a book I would not put in separate repos, but a small library that I am likely to reuse in other projects I would (even if it's just a couple of files).

(Btw, I am not necessarily suggesting the use of submodules -- for some things they work well, but also have drawbacks.)

I also prefer Mercurial.

Admittedly this is becoming harder and harder with GitKraken which is really nice.  :-*

What Jibz said.

With the specific addition that it's a repo per project, not necessarily module. Creating a repo for each submodule of a Java EE project would just be insane (you often see those split in Web, EJB and EAR modules).

Heck, at work I've been dealing with a project that consists of three EAR deployments, with use a shared 'commons' library - that's split in four Git repos. While it makes sense to have three different EAR deployments, it might as well have been contained in a single Git repo. I can't think of good reasons to have it split in four, and it makes moving code around (like, factoring out code to the common library) harder (and loses history).


[0] Message Index

[#] Next page

Go to full version