January 6, 2022 06:00 pm GMT
Original Link: https://dev.to/danyson/how-to-delete-remote-commits-in-git-11h0
How to delete remote commits in git?
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 C3git revert --no-commit B2git commit -m "commit message for your reverts"
Original Link: https://dev.to/danyson/how-to-delete-remote-commits-in-git-11h0
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To