liveBook · Manning

GitHub gist

As explained in Practical Automation with PowerShell: Effective scripting from the console to the cloud

GitHub Gist is a GitHub service for creating, publishing, and sharing small code snippets or files with version history and access controls.

GitHub Gist provides a lightweight way to publish and share one script or code snippet without creating a full repository. Each gist uses Git-based version control, supports syntax highlighting and comments, and can be public or private. section 12.1

Use a gist when you need to:

  • Upload an existing PowerShell script from the browser or with the GitHub CLI. section 12.1.1
  • Track revisions as edits are saved and automatically published as new versions. section 12.1.2
  • Share a private gist by direct URL or create a public gist with the --public switch. section 12.1.3
  • Collect comments and feedback, while moving substantial multi-person collaboration to a full repository because gist changes cannot be approved. section 12.1.3

Upload a system-information script

Save a script such as Get-SystemInfo.ps1 locally, then run `gh gist create Get-SystemInfo.ps1 --web` to create the gist and open it in a browser. The script can query Win32_OperatingSystem and select details such as the operating-system caption, architecture, build number, computer name, and total memory. section 12.1.1

gh gist create Get-SystemInfo.ps1 -–web
- Creating gist Get-SystemInfo.ps1
✓Created gist Get-SystemInfo.ps1
Opening gist.github.com/2d0f590c7dde480fba8ac0201ce6fe0f in your browser.

The GitHub CLI command and resulting browser URL show the complete upload workflow for an existing script. section 12.1.1

How Practical Automation with PowerShell: Effective scripting from the console to the cloud covers it

How deep it goes
Explains creation, editing, visibility, comments, and versioning, but defers approval-based collaboration to full repositories.
Examples
Uses Get-SystemInfo.ps1, GitHub CLI creation and editing commands, direct URLs, public visibility, and browser syntax highlighting.
What it assumes
Assumes a locally saved script and access to either gist.github.com or the configured GitHub CLI.
What you can do after
Apply it via the GitHub CLI or browser to publish, revise, share, and version a single script.
How it connects
Connects Git, GitHub CLI, version control, PowerShell scripts, and GitHub repositories.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Practical Automation with PowerShell: Effective scripting from the console to the cloud. The section links point to the parts of the book it draws on.