I've just stupidly done a
git push origin --mirror
which mirrored my local repo to the remote deleting all of my colleagues work. Is there any way to revert to the remote repo state before I pushed my local repo?
One idea: get every colleague to just type "git checkout [branch]" and "git push" for every branch that matters to them. They probably all have reasonably up-to-date local copies on their own machines.
Are you on Bitbucket Server or Bitbucket Cloud? If you're on Bitbucket Server you might be able to painstakingly recover the lost branches by sifting through the server logs and recovering the commitId / branch associations. Under the hood nothing is lost, but it can take days of menial (and error prone) log searching to recover the labels.
In the future, if you're on Bitbucket Server I recommend installing our free Control Freak for Bitbucket Server add-on, since it blocks pushes like this on the server-side right out of the box thanks to this setting (which defaults to enabled):
Block Multi-Rewrites [x] Yes [ ] No
Avoid push.default=matching disasters
With that setting in place your push would have (probably) been blocked with a warning like this:
remote: ----- remote: Push rejected. Multiple history rewrites remote: in a single push not allowed. remote: remote: Is your "push.default" config is set to "matching"? remote: Try setting it to "simple" instead. remote: remote: Trying to mirror a repo? In that case, disable remote: "Control Freak for Bitbucket Server" for this repository. remote: (Repository Settings -> Control Freak) remote: -----
I say "probably" because the push would have had to contain at least two history rewrites, which is highly likely with a "git push --mirror". In future versions of Control Freak we plan to have this logic improved to also catch accidental "git push --mirror" scenarios that have no history rewrites.
Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events