I just wanted to move my codes in the repository to other my repository and did this.
git clone --mirror [repository1 which has codes i wanted to move]
git remote set-url --push origin [repository2 which has other codes]
$ git push --mirror
and i lost my all codes of repository2 and repository1 was pasted to repository2.
can i just restore every codes of the repository2? or is there any way to undo what i did?
I googled a lot but it seems to be that no one had similar problem.
Thanks in advance!
How different was repository2 from repository1? If repository1 was just ahead of repository2 in the historical timeline, then git will allow you to revert back to the specific commits that you are hoping to find. However if they were divergent, I would be surprised if your commands even worked if you did not include a --force
flag with your git push --mirror
command. Git has checks in place to prevent this very scenario, but I'm not certain if the --mirror
flag overrides that protection or not as that is the job of the --force
flag. If not --force
flag was issued with your git push
then I am certain that somewhere in your git history are the files you are looking for. Perhaps they are in a different branch or maybe detached. Without knowing the specifics around the changes to code being made, your branching strategy, and what you have done, nobody here is going to be able to help you beyond the points I've already made.
However if you did issue a git push --mirror --force
then all bets are off and you very well may have destroyed data.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.