英文:
nested but communicating git repositories
问题
不要担心,我将为您提供代码部分的翻译,不包括问题、示例和思考部分。以下是代码部分的翻译:
让`upper`、`left`和`right`分别表示如下图所示的目录。
upper
├── left
└── right
请告诉我如果您需要任何进一步的翻译。
英文:
let upper
, left
, and right
be directories as in the following diagram.
upper
├── left
└── right
question
how do i best manage these with git as local git repositories such that
- each
upper
,left
andright
has a separate git repository, - histories from the repositories of
left
andright
can be somehow propagated to the repository ofupper
, - histories from the repository
upper
can be somehow propagated to the repositories ofleft
andright
,
both of the latter preferably being done without changing the corresponding work-trees upper
, left
, and right
?
example
for clarity, call the git repositories of upper
, left
and right
just upper.git
left.git
and right.git
respectively. (you can imagine them as bare repositories entirely outside the mentioned directory structure.) first
- i work on
left
and commit toleft.git
; then - i somehow propagate the history from
left.git
toupper.git
, so the latter knows about all the work i have done; then - i work on
upper
, sometimes working on files inright
, and commit toupper.git
; then - i somehow propagate the history from
upper.git
toright.git
, so the latter knows about all the work i have done on files inright
.
thoughts
initially i thought that i could realise this by using git subtree. but when i try to include the repository for left
in upper
using git subtree -P left add ⟨left.git⟩ master
, i - perhaps unsurprisingly - get:
fatal: prefix 'left' already exists.
i have searched similar questions on stackoverflow, regarding nested repositories, but i quite don’t see how they relate to my problem. i probably don’t understand git subtrees well enough and perhaps i’m a bit too simple-minded in general. i have not looked deeply into git submodules; it seems to me that they are meant for something else.
答案1
得分: 1
不太清楚你对这样的结构有什么最终目标。如果你只打算将所有这些存储库保留在本地 - 没有必要使用子模块。
如果你想让上级存储库(而不是文件夹)包含来自内部存储库的所有更改(独立的提交树),你可以尝试查看这里的一些答案。
另一方面,我看不出有任何理由这样做。如果你只想保留不同存储库中文件夹的更改 - 创建独立的存储库,并将它们视为独立的。在这种情况下,upper.git
存储库(而不是文件夹)将忽略内部存储库的所有更改。每个内部存储库将跟踪自己的文件夹。
英文:
It's not quite clear what is your ultimate goal for such a structure.
If you only plan on keeping all these repos local - there is no need for submodules.
If you want upper repo (not folder) to contain all changes from inner repos (separate commit tree) you could try some answers from here.
On the other hand I don't see any reason to do so. If all you want is just keep changes of folders in different repositories - create independent repos, and treat them as such. In this case upper.git
repo (not folder) will ignore all changes of inner repos. Each inner repo will keep track of it own folder.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论