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.
To revert, you can: Go to the Git history. Right click on the commit you want to revert. Select revert commit.
If you're sharing with others, don't go backwards, only ever go forwards. I think with the 2nd one you remove indeed the bad push in the remote repository BUT the history remains in your local repo. and when you do new changes, commit and push again, you will have again the bad push in the remote repo.
To remove the last commit from git, you can simply run git reset --hard HEAD^ If you are removing multiple commits from the top, you can run git reset --hard HEAD~2 to remove the last two commits.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With