Igor Djordjevic於 2017年6月22日星期四 UTC+8上午6時39分33秒寫道:
>
> On Wednesday, June 21, 2017 at 10:33:37 PM UTC+2, Igor Djordjevic wrote:
> Hmm, it may be worth noting that working with submodules like this, where 
> each one points to _exactly the same repository_ (and not being a clone of 
> it), could be pretty confusing, to say the least -- you basically end up 
> with a single repository ("main" submodule repository) with multiple 
> working trees (one inside each project using the submodule), but with 
> originating Git repository _not being aware of it_, thus not able to assist 
> with (multiple) working tree synchronization :/
>
> Not being careful enough, one can easily find himself in a pretty 
> messy/awkward situation...
>
> From this perspective, the "worktree" approach seems safer, as multiple 
> working trees are transparent/known to the originating Git repository, 
> being aware of the mechanism (and all the working trees). I`m just not sure 
> if it has drawbacks of its own...? (besides the main submodule repository 
> needing to know/keep branches/worktrees for each project using the 
> submodule)
>

The "git worktree add" will give the .git file of submodule the right path 
automatically, so you don't touch that file. 
And it creates extra folder "worktree" which store some necessary data for 
using different working tree.

For example:
  projects/project1/.git/modules/library_XYZ/*worktrees*/library_XYZ/*HEAD*

Another HEAD file for project2/library_XY!

Those worktree data allow project2/library_XYZ to use its own checkout 
commit and different working tree from project1/library_XYZ. Cool! :D

ASFAIK, you still can use "submodule update" for daily work. suppose 
no drawbacks. :)

Only modify the .git file of submodule, well, two working tree will use the 
same index file, the same branch, the same HEAD file, ... mum... as you 
said, something wrong. :P
(suppose that's way git introduce the worktree feature since git 2.5.)

Yue Lin Ho

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to