¿Cómo se sincroniza con una lista de cambios anterior en GitHub?

I come from the Perforce world, so my language here is going to be Perforce speak, but I am trying to use GitHUB and something terrible has happened. I used the commands:

git reset --hard
(and)
git clean -f -x -d
(and then)
git fetch

to attempt to revert some code I had just written.

Instead of reverting my code, all that happened to me was all of my files that were modified got deleted off the server AND off my local machine.
Unfortunately most of my code was in a single source file, and since I had modified that file it has vanished from existence, both off the server AND off my local machine.

Could someone please give me the GitHub command to sync to an older revision of the code? I'm afraid this is the only way I'm going to get my source code back...!

Does anyone know what I have done wrong here?

Thanks -Simon

preguntado el 09 de enero de 11 a las 09:01

git fetch shouldn't have published/modified anything on GitHub, but even if it did, you still can ask GitHub for the reflog (sitaramc.github.com/concepts/reflog.html) of the remote GitHub repo: the lost commit should be there, ready to be restored. Check also the reflog on your local side: gist.github.com/283992 -

1 Respuestas

Nothing should have happened on the server with the commands you listed. Even if you pushed a change you didn't want (e.g., one that deleted a file), all the history should have been preserved on the server.

Have you tried simply cloning the repository again? That might be the simplest way to ensure that your local git clone is in a sane state. After that, look through the log for the file.

If it's still not there, you must have done more than you indicated in your original question.

Respondido el 09 de enero de 11 a las 23:01

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.