When cloning a repo, that you have write access to, use the ssh protocol, instead of http. You can do that even with an existing folder, using git remote, instead of clone.
For this to work you would have to generate a new ssh key, in case you don't have one already.
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_git
and copy-paste the public key to your Github/GitLab account settings.
cat ~/.ssh/id_ed25519_git.pub
You'll no longer need to enter credentials when you git push.