Skip to content

Instantly share code, notes, and snippets.

@lpsouza
Last active August 4, 2023 19:38
Show Gist options
  • Save lpsouza/0f4e23cb81f4627543449bf04b8b1921 to your computer and use it in GitHub Desktop.
Save lpsouza/0f4e23cb81f4627543449bf04b8b1921 to your computer and use it in GitHub Desktop.
Cheatsheets - Github CLI

Github CLI Cheat Sheets

Releases

https://github.com/cli/cli/releases

Authentication

gh auth login

Gist commands

Create a new Gist from local file

gh gist create LOCAL_FILE -d "DESCRIPTION"

or

gh gist create LOCAL_FILE -d "DESCRIPTION" -p

List all Gists

gh gist list

Edit a Gist with a local file

gh gist edit GIST_ID LOCAL_FILE

Webhooks commands

Create a webhook for a repository

gh api -H "Accept: application/vnd.github+json" -X POST /repos/OWNER/REPO/hooks --input - <<< '{
  "name": "web",
  "active": true,
  "events": [
    "page_build"
  ],
  "config": {
    "url": "URL",
    "content_type": "json"
  }
}'

Get a list of all webhooks for a repository

gh api -H "Accept: application/vnd.github+json" /repos/OWNER/REPO/hooks

Delete webhooks for a repository

gh api -H "Accept: application/vnd.github+json" -X DELETE /repos/OWNER/REPO/hooks/ID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment