Reputation: 1699
A team member accidentally pushed half a gig of unwanted zips to the remote repo last night when they were in a rush. Yes... oops.
Nobody has pulled or committed since.
Ideally I want to just 'undo' what happened.
I have looked at filter-branch and was thinking of trying something like
git filter-branch --tree-filter 'rm -f *.zip' HEAD
but that would be local, and I can't figure out how to do it direct on the remote repo.
Is there a simpler way to undo what happened? If she amends her last commit and pushes again will that undo the push - ie actually remove those files from the history?
Obviously if she deletes them, commits and pushes again then that still leaves the content in the repo, which is no good.
Upvotes: 37
Views: 30212
Reputation: 10814
I think
git reset --hard HEAD^
git push -f
should to the trick: It resets your local checkout to the previous commit (assuming the last one is the one you want to drop) and force pushes it to the remote repository.
Upvotes: 7
Reputation: 1699
Thanks Don, I'd seen that but somehow hadn't realised it fixed my problem, because I only have one branch.
I did:
git push -f origin 5910117a8fc2c71334251465b54d6d9daeb28d1c:master
And it's all back to how it was.
Upvotes: 55