I'm using TortoiseGit in Windows for my git projects.
I made a local commit on my project. And I want to undo it.
How to undo git commit with TortoiseGit? without discarding my changes
If you don't want to discard the working tree changes, using Reset with Mixed option or commit it with another branch to keep it.
If you want to keep changes in a commit, do what you want to do except clean up the repository(garbage collection). Those changes can be retrieved later.
2023/12
Win10 TortoiseGit 2.15.1.0 git version 2.43.0.windows.1 Reset with Mixed optionCondition:
and
If pushing F5 to refresh, that last commit will be invisible.

I will show you how to retrieve that commit later.
Reset with Hard optionIf you don't care the Working Tree Changes nor the last commit's changes, perform Git Reset with Hard.
Also, that last commit will be invisible after pushing F5.
But, it can be retrieved.
You could create a local branch keep to keep the commit at the beginning. Like this:

If not...
Since you have done the commit, that commit will exist in the near future. So you can find it back by using Reflog.
Then, you can show log for that invisible commit, or create a local branch for it.

NOTE: Those invisible commits will be accessible until the repository is cleaned up.
Rebase with Forceand
(You may hit the conflicts, but how to resolve the conflicts is another story. :P )
NOTE: Also, you can create keep branch at beginning or by using Reflog to retrieve it later. If so, the Graph of Show Log will be:

TortoiseGit -> Show Log -> Revert change by this commit This will generate a commit that revert the commit, so you won't "lose" your changes.
Reset, it will lose the commit, unless you go to reflog as soon as possible (before garbage collection).
gitclient for this operation?