_partials/gh_cli.md
CLI is the acronym of Command-line Interface.
In this section, we will use GitHub CLI to interact with GitHub directly from the terminal.
It should already be installed on your computer from the previous commands.
We will use the GitHub CLI (gh) to connect to GitHub using SSH, a protocol to log in using SSH keys instead of the well known username/password pair.
First in order to login, copy-paste the following command in your terminal:
:warning: DO NOT edit the email
gh auth login -s 'user:email' -w --git-protocol ssh
gh will ask you few questions:
Generate a new SSH key to add to your GitHub account? Press Enter to ask gh to generate the SSH keys for you.
If you already have SSH keys, you will see instead Upload your SSH public key to your GitHub account? With the arrows, select your public key file path and press Enter.
Enter a passphrase for your new SSH key (Optional). Type something you want and that you'll remember. It's a password to protect your private key stored on your hard drive. Then press Enter.
Title for your SSH key. You can leave it at the proposed "GitHub CLI", press Enter.
You will then get the following output:
! First copy your one-time code: 0EF9-D015
- Press Enter to open github.com in your browser...
Select and copy the code (0EF9-D015 in the example), then press Enter.
Your browser will open and ask you to authorize GitHub CLI to use your GitHub account. Accept and wait a bit.
Come back to the terminal, press Enter again, and that's it.
To check that you are properly connected, type:
gh auth status
:heavy_check_mark: If you get Logged in to github.com as <YOUR USERNAME> , then all good :+1:
:x: If not, contact a teacher.