how to uncommit the changes in git code example

Example 1: how to uncommit my last commit in git

git reset --soft HEAD^

git reset HEAD^
//And if you actually want to completely undo it, throwing away all uncommitted changes, resetting everything to the previous commit (as the original question asked):

git reset --hard HEAD^

Example 2: git revert uncommitted changes

# Revert changes to modified files.
git reset --hard

# Remove all untracked files and directories.
# '-f' is force, '-d' is remove directories.
git clean -fd

Example 3: how to uncommit in git

git reset --soft HEAD^