I just made a new repository on github. Starting with a folder full of files, the steps I did were:
git init
git add -A
git remote add origin ...
#Now pull in the first commit that github made
git pull origin master
#Check everything is OK
ls
Eek! All my files have disappeared! What happened? Can I get them back?
You can get them back. Even though the only thing pointing to it was the index,
git addstill put the added content in the repo. I’d start with agit fsckto find “dangling” (git’s slightly quirky spelling of “unreferenced”) blobs andgit cat-file -pthose blobs, if there’s too many I’d do something likefind .git/objects -type f | xargs ls -lt.