GH-VARIABLE-SET(1) GitHub CLI manual GH-VARIABLE-SET(1)

# [NAME](#NAME)

gh-variable-set - Create or update variables

# [SYNOPSIS](#SYNOPSIS)

**gh variable set &lt;variable-name&gt; \[flags]**

# [DESCRIPTION](#DESCRIPTION)

Set a value for a variable on one of the following levels: - repository (default): available to GitHub Actions runs or Dependabot in a repository - environment: available to GitHub Actions runs for a deployment environment in a repository - organization: available to GitHub Actions runs or Dependabot within an organization

Organization variable can optionally be restricted to only be available to specific repositories.

# [OPTIONS](#OPTIONS)

[**-b**, **--body** **&lt;string&gt;**](#b)

The value for the variable (reads from standard input if not specified)

[**-e**, **--env** **&lt;environment&gt;**](#e)

Set deployment environment variable

[**-f**, **--env-file** **&lt;file&gt;**](#f)

Load variable names and values from a dotenv-formatted file

[**-o**, **--org** **&lt;organization&gt;**](#o)

Set organization variable

[**-r**, **--repos** **&lt;repositories&gt;**](#r)

List of repositories that can access an organization variable

[**-v**, **--visibility** **&lt;string&gt; (default "private")**](#v)

Set visibility for an organization variable: {all|private|selected}

# [OPTIONS INHERITED FROM PARENT COMMANDS](#OPTIONS_INHERITED_FROM_PARENT_COMMANDS)

[**-R**, **--repo** **&lt;\[HOST/\]OWNER/REPO&gt;**](#R)

Select another repository using the \[HOST/]OWNER/REPO format

# [EXIT CODES](#EXIT_CODES)

0: Successful execution

1: Error

2: Command canceled

4: Authentication required

NOTE: Specific commands may have additional exit codes. Refer to the command's help for more information.

# [EXAMPLE](#EXAMPLE)

```
# Add variable value for the current repository in an interactive prompt
$ gh variable set MYVARIABLE
# Read variable value from an environment variable
$ gh variable set MYVARIABLE --body "$ENV_VALUE"
# Read variable value from a file
$ gh variable set MYVARIABLE < myfile.txt
# Set variable for a deployment environment in the current repository
$ gh variable set MYVARIABLE --env myenvironment
# Set organization-level variable visible to both public and private repositories
$ gh variable set MYVARIABLE --org myOrg --visibility all
# Set organization-level variable visible to specific repositories
$ gh variable set MYVARIABLE --org myOrg --repos repo1,repo2,repo3
# Set multiple variables imported from the ".env" file
$ gh variable set -f .env
```

# [SEE ALSO](#SEE_ALSO)

[**gh-variable(1)**](/man/os/gh/gh-variable.1)

Oct 2026

---

Document: gh-variable-set(1) from gh 2.103.3-r0 (Chainguard OS)
Source: https://github.com/cli/cli
