Tell me what will happen if a folder with a git-repository is added to another git-repository?
folder structure:
Level1 /
.git
Level2 /
.git
Level3
Tell me what will happen if a folder with a git-repository is added to another git-repository?
folder structure:
Level1 /
.git
Level2 /
.git
Level3
depending on what is meant by the word "add."
if it is intended to copy / create files / directories, then the git status command executed in the “top” directory will show the untracked Level1/Level2/Level3 (if I correctly understood that Level3 is a file, not a directory). all other files / directories will not be (by default) shown as untracked because they (from the point of view of the git program) are either “empty” or their names begin with a dot.
if the word “add” implies git add Level1/.git , then you will immediately get an error:
error: Invalid path 'Level1 / .git / HEAD'
error: unable to add Level1 / .git / HEAD to index
fatal: adding files failed
developers have come up with such a protective tool: to give an error when trying to add a file to the repository with the name HEAD , located in a directory named .git .
By the way, the same applies to the .git/config , .git/description , .git/hooks/* and .git/info/* files.
so if you really need to add one repository to another, it’s better to use the “ready” submodule mechanism.
Source: https://ru.stackoverflow.com/questions/520956/
All Articles