To remove a Git commit that has not been pushed, use the git reset command. If you want to delete the commit but keep the changes in your working directory, run:
git reset –soft HEAD~1
If you want to discard the commit and the changes, use:
git reset –hard HEAD~1
Here, HEAD~1 refers to the most recent commit. Be cautious with –hard, as it permanently deletes the changes. Always ensure the commit has not been pushed to avoid impacting others working on the same branch.