In my project there is a folder with common tools that I want to include in each of my app components. I just want one master version of it and I want the rest of the copies to be updated with git commands as normal. Is there a way to do this while keeping everything in the same repository? I know got submodule works with multiple repositories but it doesn't seem like it works with just a single repository. Does anyone have any insight on the matter?
In my project there is a folder with common tools that I want to include in each of my app components. I just want one master version of it and I want the rest of the copies to be updated with git commands as normal. Is there a way to do this while keeping everything in the same repository? I know got submodule works with multiple repositories but it doesn't seem like it works with just a single repository. Does anyone have any insight on the matter?
Experimenting a little, the answer seems to be "sort-of". The command supports it with something like
git submodule add -b libfoo -- ./ libs/foo
where libfoo
is the name of the branch that the submodule exists in, ./
is a relative URL to the "upstream repository", and libs/foo
is the "working tree" of the submodule checkout (and also the default name of the submodule; you may want to override this with --name libfoo
).
Digging around a little, it doesn't quite do what you might want:
.git/modules/libs/foo/config
.git-new-workdir
does).git worktree
. Maybe this is just a matter of pointing .git/modules/libs/foo/commondir
at the enclosing repo?.git/modules/libs/foo/config
). This will break if you move your checkout somewhere else on the filesystem.git-subtrac (from the author of git-subtree) is designed around the "submodules in the same repo" idea, but I'm not sure how much it helps with the above.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.