I just tried to migrate my files for a certain repository on my local machine to another directory and appear to have failed miserably.
Having copy-pasted the source files to a new folder, I went through the following to try and make a commit to the original GitHub repository by doing the following in the new directory:
git init
git add .
git commit -m 'migration'
git remote add origin https://github.com/UN/REP.git
git push origin master
This (as I've grown used to with git by now) threw me an error:
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/UN/REP.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Clueless as to why this may be the case, I just naively forced the push
git push -f origin master
Now, none of the files have kept their edit history as the repository is showing only one (the forced) commit.
Is there any way to get the edit history back for this repository?
I read a few questions about recovery after/undoing a forced push but 1) i have no idea what they're talking about and 2) I think I may be saved by the fact that I still have the old .git folder in the old folder I was using before I migrated.