1

TLDR: I am unsure if I should be using a subtree or submodule and how to setup/use the appropriate solution.

The current workflow

I have a private repository A which has several sub-directories (e.g. a) of my research, which only I have access to. Based on some of this work I wish to have a sub-set of this work (self contained in a sub-directory b) available in a "second" repository which a second author can use to make edits. Ideally this second repository should appear to the other author like a normal repository (a master branch, github page, etc.).

A       # Main git repo
├── a   # My private work
└── b   # Work I would like a collaborator to contribute to.

My collaborator editing b should not be able to access or view anything outside of b. Hence I am weary of accidentally having a change in a logged in b if I should commit both under a single commit under A, (cf. my point of concern about committing changes a few paragraphs below).

A subdirectory should be a second repository for collaboration

If I make changes in a or b then I think this should be tracked in the A git log. If however I make changes only in a then this should not be tracked in b's git log. If a collaborator should make changes in b then I should be able to pull these.

If I make some changes in both a and b in a single commit under A, then I am a bit unsure how best this should be handled and am open to suggestions/comments. For my case I think it is best if these are split into two separate commits as b is stand-alone within A and unrelated to a. If this requires extra vigilance on my part when committing then so be it, although if this is a common pitfall and gotcha that is a nightmare to disentangle then please advise.

Subtree or submodule?

Based on a bit of reading (e.g. How do I work with a git repository within another repository?) I am struggling to differentiate between subtree and submodule, and either seem suitable. I'm not yet well versed enough to even differentiate the difference between these and the problems they are solving.

Related questions

I think the following questions are related but I don't think they quite address my situation:

  1. git submodules, subtrees or else
  2. Git: subtree or submodule for personal projects?

Currently after some more reading I think a subtree may be the best fit, but I am still uncertain, (cf. Differences between git submodule and subtree).

oliversm
  • 1,771
  • 4
  • 22
  • 44

0 Answers0