I have a a remote git repo and a local clone. Let's say I lose my local .git directory and subsequently add and remove some files to the local working directory.
At some point, I want to re-init the local repo, connect it to the remote, and ultimately push my local working dir to the remote exactly as it is (which is to say, I want to have all the added/deleted files be the same in the remote)
How would I accomplish this?
Here is my current solution, which I don't like (and may not work in all cases).
git init
git remote add origin [some_url]
git add . # adds all the files in the working dir
git commit -m "adding files"
(At this point, my current idea is to:
make a branch,
fetch the remote into it,
'git diff master branch > my_patch'
apply that patch to the branch,
push from the branch to the remote,
pull into the master,
and kill the branch.)
Clearly my idea is quite complex and ugly. Any ideas?