#git

How to permanenty delete commits from repository ?

Date : 16/09/2023 #git

To delete all the commits from remote upto a particular commits execute the below commands in the terminal-

git reset --hard <commit id>
git push origin HEAD --force

Sometimes it happens that we commit something accidently and soon we realize that we did a mistake and we have to revert the change. We can bring our latest commit to the staging area with the following command -

git reset --soft HEAD~1