When you try to clone the repository with HTTPS protocol, you must see the following message at least once.
$ git clone https://github.com/foo/bar.git Cloning into 'bar'... Username for 'https://github.com': xxx
It’s easy to resolve this issue. We just put the username and the token issued in the personal access token page in the GitHub settings.
But what if you do not have any option to set the token by yourself? In a situation like using Homebrew to clone the repository with HTTPS protocol?
We can cache the credentials of GitHub in Git so that we can use these credentials even if we do not have any way to control the external script execution.
- Please make sure to install GitHub CLI
gh auth loginand select HTTPS as your preferred procotol.
Now, you should be able to clone the repository with HTTPS protocol without specifying the username and personal access token explicitly. Git automatically takes care of that.
See the official document for more detail.