I have a local Git repository that I keep a backup copy of as follows:
git add -A
git commit -m "Initial commit"
git clone --bare /path/to/repo_backup/my_repo.git
git init --bare --shared
git remote add origin /path/to/repo_backup/my_repo.git
git push --set-upstream origin master
While I was out for two weeks, our IT department unilaterally decided to delete the .git directory that was my local repo. Changes were then made to the working directory, and I am unable to run git status to see what changes were made.
I need to restore the local repo from the backup (i.e. remote) repo without affecting the working directory (i.e. so I can't do a straight git clone).
I have attempted this via:
cp /path/to/repo_backup/my_repo.git /path/to/local/repo/.git
However when I run git status, I get this error:
fatal: this operation must be run in a work tree
How may I properly restore the local repo without affecting the working directory?