There is a working repository with a long history. The programmer accidentally executed git init in it and sent it to the server. As a result, a bunch of garbage was recorded, the rights to the files changed + everything else. An init commit cannot just be canceled ( revert ). How all the same to cancel it and return everything back?
|
1 answer
Attention! Very dangerous commands are described, potentially destructive. It is recommended to follow them with caution. Remember to make a backup just in case.
Read the entries in the reflog.
git reflogMake
git reset --hard HEAD@{N}where N is the desired commitCheck that the current point is exactly the one you need.
If you are satisfied with the state, then make
git push -f(since you managed to send to the server)
- fourFor insurance, you can leave a backup branch on the current final commit. And to do it better after you
pull, and warn all your colleagues so that they don’t throw anything in the repository. - D-side git initin the already initiated repository should not do anything at all. Explain, please, what happened to the author? - Nick Volynkin ♦
|
git initin the already existing repository does not change anything. . Maybe some other team was used? - Nick Volynkin ♦