Up until recently, I had this file structure:
-Repo A
|- .git
|- files
|- Repo B
|- .git
|- files
I then casually checked out a different branch on Repo A (simply switched branches in Github for Mac), immediately switched back, and voilà:
-Repo A
|- .git
|- files
|- Repo B
Repo B is there but empty! Not even a .git directory!
No remotes, and there goes 2 weeks of 3D modelling.
(The irony of it all is that my very first 3D-model (before all of this) went corrupt so I figured I'd use git and commit on a regular basis. And so I did...)
A nested git repo is only recorded as a gitlink, that is a special entry in the index of the main repo.
When you checkout back to your original branch, Git restores the gitlink, but has no idea to which repo that SHA1 is coming from.
To keep both SHA1 and content, you would need to declare repo
B
as a submodule.Then you would have a
.gitmodules
file in the main repoA
, which would keep a record of the repoB
remote origin url.