Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
January 6, 2022 06:00 pm GMT

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:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To