I am new to git. I wanted to push my data to my branch but instead I pushed it upstream/master branch. I want revert that push. Is there any way?
Any help is appreciated.
Revert locally and push your revert
git revert <commit_id>
git push upstream/master
This is better than deleting your history if you're collaborating with a team on the upstream repo. If you do hard reset and force push, you could end up removing other commits by other people. It's better to just roll back your changes and show that in the team history.
git checkout -b myfeaturebranch
git checkout master
git reset --hard HEAD~1
git push --force
This does the following:
The danger here is if anyone else pulled from master those commits will be lost. In that case, you'll want to use revert
instead of reset
which will record the reset as part of the commit history.
git checkout -b myfeaturebranch
git checkout master
git revert HEAD~1
git push
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