LinuxCommandLibrary

gh-at

List or download GitHub Actions artifacts

TLDR

View documentation for the original command

$ tldr gh attestation
copy

SYNOPSIS

gh at [ref] [--porcelain]

PARAMETERS

ref
    Git reference (branch, tag, SHA prefix) to resolve; defaults to HEAD

--porcelain
    Output plain SHA without decoration for scripting

-h, --help
    Display help and exit

DESCRIPTION

gh at is a subcommand of the GitHub CLI (gh) that resolves a git reference to its full commit SHA hash. It simplifies obtaining the exact commit identifier from branches, tags, or partial SHAs, defaulting to HEAD if no ref is provided.

This command is particularly useful in scripts, CI/CD workflows, or automation where you need a reliable, formatted commit hash without parsing complex git output. For instance, it ensures consistent SHA retrieval across environments.

Without flags, it prints the SHA with some formatting. The --porcelain option outputs a plain, machine-readable SHA for easy parsing in pipelines.

Run within a git repository. It leverages git internals like rev-parse but provides a cleaner interface tailored for GitHub workflows. Errors occur if the ref is invalid, exiting with code 1.

Example usage boosts productivity in GitHub Actions or shell scripts needing commit anchors.

CAVEATS

Requires a git repository; fails (exit 1) on invalid refs. GitHub CLI authentication unnecessary for this local operation.

EXAMPLES

gh at main
Prints SHA of main branch.

gh at v1.0 --porcelain
Raw SHA of tag v1.0.

HISTORY

Introduced in GitHub CLI v2.11.0 (Oct 2022) to streamline ref resolution in workflows.

SEE ALSO

git rev-parse(1), git show-ref(1), gh(1)

Copied to clipboard