“git push --mirror” deleted remote tags. Any way to restore them?
문제
Before jumping to answer, please read this mess carefully!
Problem:
- I am working on a project (using git for version control).
- I created tag v2.x and pushed it to my remote origin.
- 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.
- Unaware of this, I added another remote to our public github repo.
- 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:
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.
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.
해결책
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:
- Intialize a git repo locally, add some files into it and commit it.
- 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...
다른 팁
Here is a very pertinent solution to undoing git push -mirror
.
git push --tags
from another local git repository which has all previous tags would help.