I have been reading an article in which the author instructed: creating a new repository within an existing one, and wondered if it was an error he overlooked. I will verify with him later.
These are the conditions I want to check:
-
The condition when an existing directory is made into a repository,
and files already checked into the main project are also checked in
the new (sub) repository. Is this possible? -
When a directory tree which contains git repositories is checked in
for the first time -
When a new empty repository is created under the repository, either
by git init, or by copying a .git repository into a new or empty
directory?
As mentioned in “Git repository in a git repository“, the nested repo is mostly ignored by the parent repo (only a gitlink is recorded)
So any operation on the parent repo won’t have an incidence on the nested repo.
If you declared the nested repo as a submodule though, then you can checkout the parent repo and the nested repo, but that submodule will always reference a fixed commit.
If you make any modification in the submodule, you need to commit them, push them and go back to the parent repo, commit and push (to record the new fixed commit of the submodule).
See “True nature of submodules“.