how to delete previous commits from a git repo code example Example: how to delete old commits in github git reset --hard HEAD^ git push origin -f