How to best share code with SmartGit [closed]
Asked Answered
S

2

8

I have a number of separate projects that share some common code. What is the best practice for accomplishing this in Git, and specifically SmartGit?

  • Have everything in one giant repository

  • Have a repository for each project, and a repository for shared code, and use Git Submodules.

  • Have a repository for each project, and a repository for shared code, and use Git Subtrees. Can anyone tell me if this is supported by SmartGit, and how it can be achieved?

What are the potential pitfalls with these methods, and what are the best practices with SmartGit?

Shipshape answered 17/11, 2011 at 16:57 Comment(0)
F
6

I'd recommend to either have one repository for all projects or use Submodules:

  • If your common code is closely tied together with your projects, refactorings and other kind of (API) changes of your common code will likely require changes in all of your projects, so if you can do everything with one commit in one repository, you will spend less time with doing version control (with Git). For instance, Git Submodules can't simply point to the HEAD of a branch, but only to a specific commit. It can get cumbersome to always update your submodules to the latest commit.

  • If your common code is more like an independent library and it's sufficient to update your projects from time to time with newer versions of that library, Submodules will be the better choice. They are well supported with SmartGit and having separate repositories gives you e.g. the flexibility to share only some of your repositories with others, later.

  • There is no special support for Subtrees in SmartGit.

Fredrick answered 17/11, 2011 at 17:23 Comment(3)
+1, Very helpful. Are there any disadvantages to the first option? Whenever I release a version of one of my projects, would I simply branch the entire repository?Shipshape
Branching the entire repository will work well, Git e.g. allows branch names like 'project1/branch1' (internally: /refs/heads/project1/branch1).Fredrick
The main disadvantage with one big repository is that it can't be separated afterwards (AFAIK). Scalability regarding number of projects will most likely be no issue as Git is efficient also for large repositories. SmartGit's Refreshing times will however grow with increasing working tree size (Refreshing is required quite often). Just to give you an idea: if your one big repository will contain around 10K files, you don't need to bother about that.Fredrick
A
1

I'd use separate projects as well. We have hit memory issues with larger files and git + SmartGit. I'm in dialog with syntevo at the moment. With the latest version of SmartGit, the ability to copy comments is very helpful. Hope this helps

Azaleeazan answered 18/11, 2011 at 18:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.