How to undo "git push –mirror" when I only got remote repository


I wanted to add one repository’s commits in another repository.
But I think I made a big mistake.

If I assume that the one is ‘A’, and the other is ‘B’, Firstly, I did git clone --mirror

$ git clone --mirror
Cloning into bare repository 'A.git'...
remote: Enumerating objects: 65, done.
remote: Counting objects: 100% (65/65), done.
remote: Compressing objects: 100% (51/51), done.
remote: Total 65 (delta 23), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (65/65), 17.06 KiB | 1.90 MiB/s, done.
Resolving deltas: 100% (23/23), done.
cd A.git

And then, I did git push --mirror

$ git push --mirror
Enumerating objects: 65, done.
Counting objects: 100% (65/65), done.
Delta compression using up to 8 threads
Compressing objects: 100% (28/28), done.
Writing objects: 100% (65/65), 17.06 KiB | 5.69 MiB/s, done.
Total 65 (delta 23), reused 65 (delta 23), pack-reused 0
remote: Resolving deltas: 100% (23/23), done.
 + bf2d968...34bc087 main -> main (forced update)

when I check the remote repository, all the origin commits in B were gone. Also history of B became same as A.

And I don’t have local repository of A or B because I just kept upload files from colab.

I just want to know if there’s a way. Or do I need to email github?


The easiest fix : if you (or anyone) have a clone of B with the correct version of master : you (or they) can push it back to B.

Otherwise : github has an Events api (the possible events returned by this api are listed here), which provides some sort of log of actions taken on the repo.

Look for events with type: "PushEvent".

Answered By – LeGEC

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published