Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"git push --mirror" deleted remote tags. Any way to restore them?

Before jumping to answer, please read this mess carefully!

Problem:

  1. I am working on a project (using git for version control).
  2. I created tag v2.x and pushed it to my remote origin.
  3. This remote origin is a private mirror which was do NOT have tags in 1.x series. Reason - we started coding from scratch in v2.x, so 1.x is maintained for historical reason only.
  4. Unaware of this, I added another remote to our public github repo.
  5. I thought lets mirror latest tags and commits to github (as I am the only developer - I did not bother to merge!)

I used:

git push --mirror

and it deleted all tags in in 1.x series from Github!

Current Situation:

  • I googled a lot, read git manuals. Tried running git reflog/reset/rebase but not able to restore anything.
  • My local env. do not have have commits related to tag 1.x since we started from scratch in 2.x
  • Even I fail to recover anything so far, I see remote commits on Github. e.g. https://github.com/rtCamp/buddypress-media/commit/4614fcdacfbe21dae88e50e66707ef57b786ee37

That means data is present in remote...

What might work:

  1. If I can clone Github repo with all logs, including logs about deleted "commits" locally, then my "local" will have deleted commits also. After that it may be git reflog/rebase/reset exercise.

  2. I assume since remote git is a complete repo itself and its showing commits by SHA1 hashes, if I can run git reflog/rebase/reset on "remote" things may work in theory.

Please note that I am looking for pure git way. Manually we can download "tags" (zips), restore from SVN (we were using SVN during 1.x)

Please let me know your suggestions/workarounds.

like image 390
rahul286 Avatar asked Sep 04 '12 13:09

rahul286


1 Answers

I learned hard way that data in git can be lost.

There is no answer to my question. I had to do some manual work (copying old tags form old svn archives + downloading some zipped version and tagging them, etc)

So, if you do:

  1. Intialize a git repo locally, add some files into it and commit it.
  2. Then change remote origin and then do git push --mirror to a remote server

Remote repo will be a complete mirror of your local repo. There is no way to undo this if remote repo has so other clones/backup/mirror etc.

Of-course what I did (accidentally) was non-standard way so git is not responsible for it...

like image 141
rahul286 Avatar answered Sep 22 '22 16:09

rahul286