Following the steps in https://learn.microsoft.com/en-us/training/modules/github-copilot-across-environments/4-git-hub-copilot-for-the-command-line
After installing gh
, I tried to run gh copilot explain "sudo apt-get"
, but I receive the error Error: No valid GitHub CLI OAuth token detected
~ % gh copilot explain "sudo apt-get"
✗ Error: No valid GitHub CLI OAuth token detected
To get started with GitHub Copilot in the CLI, please run: gh auth login --web -h github.com to authenticate via web browser.
Then I run gh auth login --web -h github.com
then I have another error.
~ % gh auth login --web -h github.com
The value of the GITHUB_TOKEN environment variable is being used for authentication.
To have GitHub CLI store credentials instead, first clear the value from the environment.
I have GITHUB_TOKEN
set in .zshrc
export GITHUB_TOKEN=ghp_************************************
How do I run gh auth login --web -h github.com to authenticate via web browser
?
Add this line alias gh="env -u GITHUB_TOKEN gh $1"
in .zshrc
export GITHUB_TOKEN=ghp_************************************
alias gh="env -u GITHUB_TOKEN gh $1"` in ``.zshrc`
Ref: https://github.com/cli/cli/issues/3799#issuecomment-1739270630