To delete or remove git commits while keeping the changes, you can use the interactive rebase feature provided by Git. Here are the steps to accomplish this:
git rebase -i HEAD~N
N with the number of commits you want to remove. For example, if you want to remove the last three commits, use
Please note that rewriting Git history can have consequences if other people have cloned the repository. So, it's recommended to avoid using this method if your commits have already been pushed to a shared repository.