gh Verified current stable Not installed? Version Control

Gh / Set Organization Variable Visible To All Repos

Set Organization Variable Visible To All Repos

Easily set an organization variable in GitHub to be visible across all repositories with this command.

$
Terminal
gh variable set <name> -o <organization> -v all

When To Use

Setting organization-wide variables for CI/CD pipeline requirements.

Terminal Output

Expected runtime feedback

Simulated preview
>
Output
Variable 'MY_VAR' set to be visible to all repositories in organization 'my-org'.

Visibility: all
Organization: my-org
Variable Name: MY_VAR

Power User Variants

Optimized versions

gh variable set MY_VAR -o my-org -v all

Set MY_VAR as visible to all repos in my-org.

gh variable set MY_VAR --org my-org --visibility all

Set MY_VAR as visible to all repos in my-org using long options.

Troubleshooting

Common pitfalls

Invalid organization name

Solution: Ensure the organization name is correct and you have access.

Variable name already exists

Solution: Choose a different variable name or update the existing one.

Command Breakdown

What each part is doing

gh
Base Command
The executable that performs this operation. Here it runs Gh before the shell applies any redirect operators.
<name>
name
The value supplied for name.
-o
o| org
The value supplied for o| org.
<organization>
organization
The value supplied for organization.
-v
v| visibility
The value supplied for v| visibility.
-o
Command Option
Tool-specific option used by this command invocation.
-v
Command Option
Tool-specific option used by this command invocation.

How To Run

Execution path

  1. Step 1

    Replace {{name}} with the variable name you want to set.

  2. Step 2

    Use -o or --org to specify the organization name.

  3. Step 3

    Add -v or --visibility to set it to 'all'.

Alternative Approaches

Comparable commands in other tools

Alternative version control tools for the same job.