Danyson
Posted on January 6, 2022
Assume you have pushed commits in order A1 => B2 => C3 in remote repository.
Now you want to delete commits C3 and B2.
The simple solution is as follows using git reset
git reset --hard <A1-commit-id>
git push -f origin <branch-name>
However, you should avoid doing this if anyone else is working with your remote repository and has pulled your changes C3 and B2.
That's where git revert
comes in
git revert --no-commit C3
git revert --no-commit B2
git commit -m "commit message for your reverts"
Avail My IT Services on https://danyson.netlify.app/
💖 💪 🙅 🚩
Danyson
Posted on January 6, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
github A Deep Dive Into GitHub Actions From Software Development to Data Engineering
October 19, 2024