Reputation: 796
I had a git accident.
I was working on a local branch "feature1"
I wanted to do "git push not-origin feature1:master"
instead I accidentally did "git push origin feature1:master"
.
It made a lot of mess and made the commits interleave (not that I can just revert a specific commit)
Is there any way to revert this considering I did not have an updated version of master locally so I can't just force push it?
PS: I did not find any way to block pushes to master without upgrading to Enterprise which is to expensive for this eature...
Upvotes: 1
Views: 2003
Reputation: 77053
Is there any way to revert this considering I did not have an updated version of master locally so i can't just force push it?
I think you are mistaken there; As long as you didn't do a forced push (a push with the --forced
flag), the git push
would have succeeded only if the remote refs lied on the path from current ref, i.e., your current branch did not diverge from your remote master branch.
This would mean that your branch feature1
has some commit C
, which was what the master
was pointing at.
So all you need to do is figure C
out, create a new branch using git branch master_recovered C
, and force push this branch to master using git push -f origin master_recovered:master
.
Upvotes: 4