So I added a remote, empty repository to a local repository that was just initialized, and made the mistake of pulling before committing my local changes:
git init
git remote add origin <URL>
git add *
git pull origin master
Now all my files have been removed because git wrote the empty repo into the local one.
Normally, when pulling, git refused to merge if there were unstaged local changes that needed committing. I’m surprised that this is different with the initial commit.
git log shows only the initial commit since I never committed the local changes, so I can’t undo the pull using git reset --hard. Is there a way to restore my files and if so, how?
Judging by the work-flow you gave above, it appears that you staged your files. That should leave some dangling blobs out there, that you should be able to recover.
That should commit the changes to a file in .git/lost-found. Something might show up there.
Further discussion: Recover file after git pull, Recovering added file after doing git reset –hard HEAD^