Much simpler, as I explained in “How to sign out in Git Bash console in Windows?”:
git credential-manager erase <url>
Here
git credential-manager erase https://github.com
No need to remove the credential helper which is practical for caching user’s password.
Or (replace xxx wit the output of git config --global credential.helper
):
printf "protocol=https\nhost=github.com" | git-credential-xxx erase
# Windows (2020-2021)
printf "protocol=https\nhost=github.com" | git-credential-manager-core erase
# Linux
printf "protocol=https\nhost=github.com" | git-credential-libsecret erase
# MacOs
printf "protocol=https\nhost=github.com" | git-credential-osxkeychain erase