GitHub CLI 2 cheatsheet

GitHub CLI 2: Setup and repositories

7 common GitHub CLI 2 tasks.

Check the gh version

Print the installed GitHub CLI version.

gh --version

Sign in to GitHub

Authenticate gh through a browser or a token.

gh auth login

Check who you are signed in as

Show the accounts and token scopes gh has.

gh auth status

Clone a repository

Clone with your preferred protocol.

gh repo clone owner/repo

Create a repository from the current folder

Create a public repository on GitHub, set it as origin and push.

gh repo create my-repo --public --source=. --push

Fork a repository

Fork a repository and clone your fork.

gh repo fork owner/repo --clone

Open the repository in a browser

Open the repository, or a file or PR, on github.com.

gh browse

Was this page helpful?