I careless copied .git from one project (A) to another (B), with a remote scp -r (A) (B).
I would like to recover a usable state of the git repo. I can remove (A)'s .git objects. From there, how can I best go about finding tips of git branches and rebuilding a useful state of the repo.
Unfortunately, I don't have another copy of (B), and my mistake wiped out the metadata.
For A you should be able to just clone a fresh copy of it (if there is a remote) into a new folder "A_copy":
git clone <url> A_copyor for a specific branch:
git clone <url> -b some_branch A_copyThen take the .git folder from this copy and drop it into your "broken" A. Then use
git statusto see what has changed.If you want to revert either just use your new clone or you can do:
git reset HEAD --hard- this takes you back to the state of HEAD.For B, if you at least have the files and you want to turn it back into a repo you can just do the following:
git init- makes the folder a git repogit add -A- note this will add everything in this folder so tidy up first if you need to and maybe add a .gitingore if required.git commit -m "gehhh... had to start again :("