# Step 1: Find the commit hash of the commit you want to delete
git log
# Step 2: Revert the target commit and create a new commit
git revert <commit_hash>
# Step 3: Delete the original commit (optional)
git branch temp # Create a temporary branch to keep original commit
git rebase -i <commit_hash>~1 # Starts interactive rebase
# In the interactive editor that appears, delete the line for the original commit
# Save and exit the editor
# Note: Be cautious when modifying the commit history
# Step 4: Push the changes to remote repository
git push origin <branch_name> --force-with-lease