Use git-credential-manager
brew install --cask git-credential-manager
When you use git next time, it will automatically ask to open as to open in a web browser and authenticate you. You dont have to worry about configuring permissions yourself.