LinuxCommandLibrary

gh-org

Manage GitHub organizations

TLDR

List organizations for the authenticated user

$ gh org [[ls|list]]
copy

List a certain amount of organizations (defaults to 30)
$ gh org [[ls|list]] [[-L|--limit]] [100]
copy

Display help
$ gh org --help
copy

SYNOPSIS

gh org <command> [<args>...] [flags]

PARAMETERS

--help, -h
    Show help for command

--version, -v
    Show gh version

--limit <int>
    Maximum number of results to return

--json
    Print output in JSON format (only for some subcommands)

--template <string>
    Format JSON output using Go template

--jq <expression>
    Filter JSON output using jq expression

--paginate
    Automatically paginate output (global gh flag)

DESCRIPTION

The gh org command, part of the official GitHub CLI (gh), enables users to manage GitHub organizations directly from the terminal. It supports listing organizations a user belongs to, viewing and modifying memberships, creating/deleting repositories within an org, and more. This eliminates the need for a web browser, streamlining workflows for developers and administrators.

Key subcommands include list to enumerate orgs, repo for org-level repo operations like listing or cloning all repos, and membership for handling user roles (e.g., view, add, remove). Flags like --json allow machine-readable output, --limit caps results, and --jq enables filtering. Requires GitHub CLI installation and authentication via gh auth login.

Ideal for automation in scripts, CI/CD pipelines, or daily org maintenance, it integrates seamlessly with git. Usage assumes a GitHub account with org access.

CAVEATS

Requires GitHub CLI installed and authenticated user with org permissions. Not all subcommands support all flags; check gh org <command> --help. Rate-limited by GitHub API.

COMMON SUBCOMMANDS

gh org list: List user's orgs.
gh org repo list <org>: List org repos.
gh org membership view <org> <user>: Check membership.

AUTHENTICATION

Run gh auth login first. Supports GitHub.com, Enterprise, PATs.

HISTORY

Introduced in GitHub CLI v0.5.0 (February 2020). Evolved with CLI releases; current features stabilized by v2.0+ (2022). Developed by GitHub to replace deprecated hub.

SEE ALSO

gh(1), git(1), hub(1)

Copied to clipboard