Information

Author(s) Mathieu Jadin
Deadline No deadline
Submission limit No limitation

Sign in

Git Disaster Scenario 3 - Back up some code after erasing the local and remote histories

You have been careless when using git reset --hard and you then erase the remote history with git push --force.

The modifications you made are no longer in the staging zone, neither locally nor remotely. However, you can fetch your modifications back as long as you did not delete the folder .git of your project!

To do this, you need to modify the reference logs, accessible using git reflog. These logs contain all the changes made on all branches in your history. You may thus get back all the commits that you erased. Once you identified the reference you want to get back to, you may use git merge to back up the modifications in your repository (and use git push to push these changes to the remote repository).


Téléchargez l'archive qui contient déjà un repository cloné dans le sous-dossier clone. Votre repo a des historiques locaux et distants avec juste un commit suite à une mauvaise commande. Utilisez reflog pour retrouver tous les commits effacés et pusher-les sur le repository distant.

Une fois que c'est fait, ré-archivez le dossier complet et uploadez-le.

Notez que le repository "distant" dans cet exercice n'est pas sur github ou dans bitbucket mais dans le dossier bare.git de l'archive.

git-reflog/
├── bare.git/
|   └── [...]
└── clone/
    └── [...]

Max file size: 1.0 MiB
Allowed extensions: .zip