2

Projects A and B both use library project L:

A and B depend on L

Judging by what people have written about it on the web, managing this situation appears to be a headache:

http://codingkilledthecat.wordpress.com/2012/04/28/why-your-company-shouldnt-use-git-submodules/ why you shouldn't use Mercurial subrepos

Are there any solutions out there that avoid difficulties such as:

• Losing work because the VCS did something unexpected
• Hellish subrepo merges
• Screwups caused by the VCS pointing to an unexpected version of the submodule,
   frequently made worse because the user didn't realize that had happened

2
  • Have you had a look at Git Subtree instead of subrepo?
    – James
    Oct 10, 2014 at 22:38
  • Noticed its existence is about it. I just saw that sourcetree supports it, which could be a good sign. Oct 11, 2014 at 1:02

1 Answer 1

1

There is absolutely no reason to avoid git submodule; it works far better than most of the alternative "solutions". Just have your build script assert (but not modify; to solve problem 1) that the submodule is present and up-to-date (solves problem 3), and only make changes to the submodule as its own repo, not as if it's part of the main repo (solves problem 2). I'll repeat that: only make changes to the submodule as its own repo.

Additionally, recent versions of git supply git submodule update --remote to automatically pull the latest version from the branched you're tracking.

Assuming you are not completely ignoring the most important git command of all time, git status (whose output is also included in the editor when you run git commit), you won't have any problems.

Of course, if you're using some GUI frontend, it's probably crap, but that's true whether you're using submodules or not.

2
  • 1
    Nice post except for the unnecessary GUI remark Oct 11, 2014 at 12:16
  • @HaraldScheirich it's far from unnecessary. I have never seen any GUI that exposes all the power of the underlying command-line API.
    – o11c
    Oct 11, 2014 at 18:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.