I have a big project(let's say A repo
), and it there one child folder which is come from B repo
. I would meet warning like below when I commit from 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.
I have seen git-submodule
and git-subtree
:
Maintaining Git repo inside another git repo
https://www.atlassian.com/blog/git/alternatives-to-git-submodule-git-subtree
But I don't like them , because they need extra config.
What I want is , for example:
structure like:
A/
--- a.py
--- B/
--- B/b.py
When I change B/b.py
.
If I am on path A/
, git add
can detect B/b.py
changed, git push
only commit that to A repo.
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 )
If I am on path A/B/
, git add
only add B/b.py
changes to B repo, and git push
only commit that to B repo.
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/ )
Once I want to snyc A and B in another machine, just do
git clone A
rm -rf A/B/
git clone B ./B
git add . && git commit 'sync with B'
In another word, A and B act as a standalone repo.
But the truth is , A repo treat B repo as submodule:
A repo
https://github.com/eromoe/test
B repo
https://github.com/eromoe/test2
How do I force A repo track all files under A/
, and B repo track all files under A/B/
? I want A and B act as a self-contain repo , without any other config.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…