Undo git push mirror

1.1k views Asked by At

I have a server with my project. I wanted to migrate to github. I did a push --mirror to github. I checked if backup could be done in reverse So I did a push --mirror to my server. But here is what I get:

To <adresse.git>
 + 1e35d97...3ef6b80 master -> master (forced update)
   c46a188..3ef6b80  origin/HEAD -> origin/HEAD
   c46a188..3ef6b80  origin/master -> origin/master
 - [deleted]         1.0.0
 - [deleted]         1.0.1
 - [deleted]         1.0.2
 - [deleted]         1.0.3
 - [deleted]         1.0.4
 - [deleted]         1.0.5
 - [deleted]         1.1.0
 - [deleted]         1.1.1
 - [deleted]         1.2.0
 - [deleted]         1.2.1
 - [deleted]         1.2_alpha1
 - [deleted]         1.3_alpha1
 - [deleted]         1.4_alpha1
 - [deleted]         4.0.0
 - [deleted]         5.0.0
 - [deleted]         5.0.1
 - [deleted]         xvp_current

I didn't noticed (Ooooh mistake..) and did a last push --mirror from my server to github this morning which conclude by the last same output.. Those are my releases. Is there any way to cancel mirror or to get back the releases ?

Thanks in advance!

2

There are 2 answers

1
Marcus Müller On BEST ANSWER

Ok, so here's my analogy:

You went to the library, got a book on history (your clone of the git repo, which includes all the history).

Now, you've made a lot of changes, additions to that history book, which is what you're probably being paid for.

Accidentially, you returned the whole history book, including your additions.

Now you're noticing your mistake and are a little upset, because your notes weren't meant for the public.

You return to the library. If you're nice to the librarian, you might even replace the book in the shelf with the freshly bought copy that you have with you (from somewhere else, or by reconstructing it from your copies of the book), but you will never be able to undo the fact that someone else might have gotten the book between you returning it and you noticing your mistake.

To conclude: you can something like git push origin :branch1 to delete branch1 from the origin remote, if you have the right to do something like that, you can even re-write history of any branch by doing a git push --force origin branch, but this will never solve the fact that what has been seen by someone else cannot be unseen, and even worse, because they have git, it will be archived at their site for as long as these people want.

Regarding the fact that you've deleted tags: Well, bad luck. Find another copy of your book and push the tags from there.

0
nsvir On

I took a backed up project and just did:

git push --tags