Git uses credential helpers behind the scene to store your credentials.
You can check which credential-helper is configured on your system by running git config --list and lookin up for credential.helper or by just running git config credential.helper.
On windows, older versions of git(before Git 2.29) use Git Credential Manager For Windows and have default helper set as credential.helper=manager whereas, newer Git releases( Git 2.29 or later) use Git Credential Manager Core and have the default helper configured as credential.helper=manager-core.
I don't have any experience working with OSX, but as far as the online sources say, the git config credential.helper returns credential.helper=osxkeychain.
You can tell git to store credentials by running the git credential approve command followed by key-value pairs of protocol, host, username and password :
git credential approve
protocol=https
host=github.com
username=<user-name>
password=<pwd/token>
Hit RETURN/ENTER key Twice
Your credentials should now be saved.
You can confirm that by running git fill command:
git credential fill
protocol=https
host=github.com
Hit RETURN/ENTER Key twice
Running the above should return the credentials.
I have a windows system. But since git's commands should work almost the same on any OS, this should work fine on Mac as well.