我有一个大项目(比方说A repo
),其中有一个子文件夹来自B repo
。当我提交时,我会遇到如下警告A repo
warning: adding embedded git repository: extractor/annotator-server
hint: You've added another git repository inside your current repository.
hint: Clones of the outer repository will not contain the contents of
hint: the embedded repository and will not know how to obtain it.
hint: If you meant to add a submodule, use:
hint:
hint: git submodule add <url> extractor/annotator-server
hint:
hint: If you added this path by mistake, you can remove it from the
hint: index with:
hint:
hint: git rm --cached extractor/annotator-server
hint:
hint: See "git help submodule" for more information.
我见过git-submodule
and git-subtree
:
在另一个 git 存储库中维护 Git 存储库 https://stackoverflow.com/questions/36236484/maintaining-git-repo-inside-another-git-repo
https://www.atlassian.com/blog/git/alternatives-to-git-submodule-git-subtree https://www.atlassian.com/blog/git/alternatives-to-git-submodule-git-subtree
但我不喜欢它们,因为它们需要额外的配置。
我想要的是,例如:
结构如:
A/
--- a.py
--- B/
--- B/b.py
当我改变时B/b.py
.
-
如果我在路上A/
, git add
可以检测到B/b.py
改变了,git push
只将其提交给 A 存储库。
git add . (would add changes under A/ )
git push (would push changes under A/ )
git pull (would pull changes under A/ )
git clone XXX:A (would clone all files under A/ , A/B/ is just looks like plain folder with all files, not a repo )
-
如果我在路上A/B/
, git add
只添加B/b.py
对 B 存储库的更改,以及git push
只将其提交给 B 存储库。
git add . (would add changes under B/ , but not add changes to A repo)
git push (would push changes under B/ , but not push changes to A repo)
git pull (would clone changes under B/ , )
git clone XXX:B (would clone all files under B/ )
-
一旦我想在另一台机器上同步A和B,就这样做
git clone A
rm -rf A/B/
git clone B ./B
git add . && git commit 'sync with B'
换句话说,A 和 B 充当独立的存储库。
但事实是,A repo 将 B repo 视为子模块:
A repo
https://github.com/eromoe/test https://github.com/eromoe/test
B repo
https://github.com/eromoe/test2 https://github.com/eromoe/test2
如何强制存储库跟踪其下的所有文件A/
和 B 存储库跟踪下的所有文件A/B/
?我希望 A 和 B 充当独立的存储库,无需任何其他配置。