2

I have a long-standing personal repository for "Resume/", holding my resume contents. I have also had a subdir "Resume/Cover Letter", holding my CV contents that had worked well. I had created a second git repository inside "Resume/Cover Letter" awhile back, did not think much of it. Now these contents are gone! How can this be though, there is no .gitmodules in my 'Resume' project.

I can see all record of the Cover Letter repo in the log for Resume/ -

History Example:

But the contents of "Resume/Cover Letter" is empty. Where did these files go? Can they be retrieved? Here is a useful illustration -

Example

Update

Doh! See the reference below, for clear warning not to do this -

enter image description here

J-Dizzle
  • 4,861
  • 4
  • 40
  • 50
  • 2
    A Git repository cannot hold a Git repository, so when Git encounters a sub-directory that looks like a work-tree with a Git repository in it, Git treats it as a submodule, *even if there is no `.gitmodules` file*. You end up with commits in the superproject that just record the hash ID of whatever commit is currently checked out in the submodule. You're just missing the instructions that a new clone needs, in order to *clone* that submodule. – torek May 29 '20 at 02:27
  • 2
    There's no standard Git terminology for this, but I have taken to calling them "half assed submodules". They're kind of pernicious. – torek May 29 '20 at 02:28
  • @torek agreed! Thank you, your identification of risk and disposition are very clear with articulation, this is appreciated – J-Dizzle May 29 '20 at 02:31
  • 1
    As for getting back the files you want ... do you know where there's a good clone of the submodule? – torek May 29 '20 at 02:32
  • No there isn’t one! I was surprised on this, part of the learning and growth here for me I think – J-Dizzle May 29 '20 at 02:34

1 Answers1

2

When you have a nested Git repository, your parent repo only records a gitlink (a special entry in the index)

So git add/git commit/git push done in the main repository does not add/commit/push files in the nested Git repository at all.
The same command done in the nested repo folder itself would have added/committed/pushed your files.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Would adding ‘Cover Letter/.git’ to the Resume’s .gitignore fix this? – J-Dizzle May 29 '20 at 06:21
  • @J-Dizzle No, only `Cover Letter/`. But that does not change the fact you would need to go to that folder, define a remote repository, add, commit and push (again, from the `‘Cover Letter` folder) in order to have your changes saved. – VonC May 29 '20 at 06:23