em-edit --id --field-id --project-id --text "new text" # Clear an item's field value $ gh project item-edit --id --field-id --project-id --clear query RepositoryList(%s) { %s { login repositories(first: $perPage, after: $endCursor, privacy: $privacy, isFork: $fork, ownerAffiliations: OWNER, orderBy: { field: PUSHED_AT, direction: DESC }) { nodes{%s} totalCount pageInfo{hasNextPage,endCursor} } } } query RepositoryFindFork($owner: String!, $repo: String!, $limit: Int!) { repository(owner: $owner, name: $repo) { forks(first: $limit, affiliations: [OWNER, COLLABORATOR]) { nodes { id name owner { login } url viewerPermission } } } } $ gh codespace cp -e README.md 'remote:/workspaces/$RepositoryName/' $ gh codespace cp -e 'remote:~/*.go' ./gofiles/ $ gh codespace cp -e 'remote:/workspaces/myproj/go.{mod,sum}' ./gofiles/ $ gh codespace cp -e -- -F ~/.ssh/codespaces_config 'remote:~/*.go' ./gofiles/ # List rulesets in the current repository $ gh ruleset list # List rulesets in a different repository, including those configured at higher levels $ gh ruleset list --repo owner/repo --parents # List rulesets in an organization $ gh ruleset list --org org-name query PullRequestSearch( $q: String!, $type: SearchType!, $limit: Int!, $endCursor: String, ) { search(query: $q, type: $type, first: $limit, after: $endCursor) { issueCount nodes { ...pr } pageInfo { hasNextPage endCursor } } } Add a deploy key to a GitHub repository. Note that any key added by gh will be associated with the current authentication token. If you de-authorize the GitHub CLI app or authentication token from your account, any deploy keys added by GitHub CLI will be removed as well. # View credits for the current repository $ gh repo credits # View credits for a specific repository $ gh repo credits cool/repo # Print a non-animated thank you $ gh repo credits -s # Pipe to just print the contributors, one per line $ gh repo credits | cat Display the description and the README of a GitHub repository. With no argument, the repository for the current directory is displayed. With %[1]s--web%[1]s, open the repository in a web browser instead. With %[1]s--branch%[1]s, view a specific branch of the repository. Edit either a draft issue or a project item. Both usages require the ID of the item to edit. For non-draft issues, the ID of the project is also required, and only a single field value can be updated per invocation. Remove project item field value using %[1]s--clear%[1]s flag. (?=[\w\-])(CASE|CLEARGIF|COA|COA_INT|COBJ_ARRAY|COLUMNS|CONTENT|CTABLE|EDITPANEL|FILE|FILES|FLUIDTEMPLATE|FORM|HMENU|HRULER|HTML|IMAGE|IMGTEXT|IMG_RESOURCE|LOAD_REGISTER|MEDIA|MULTIMEDIA|OTABLE|PAGE|QTOBJECT|RECORDS|RESTORE_REGISTER|SEARCHRESULT|SVG|SWFOBJECT|TEMPLATE|TEXT|USER|USER_INT)(?![\w\-]) Host cs.{{.Name}}.{{.EscapedRef}} User {{.SSHUser}} ProxyCommand {{.GHExec}} cs ssh -c {{.Name}} --stdio -- -i {{.AutomaticIdentityFilePath}} UserKnownHostsFile=/dev/null StrictHostKeyChecking no LogLevel quiet ControlMaster auto IdentityFile {{.AutomaticIdentityFilePath}} $ gh pr create --title "The bug is fixed" --body "Everything works again" $ gh pr create --reviewer monalisa,hubot --reviewer myorg/team-name $ gh pr create --project "Roadmap" $ gh pr create --base develop --head monalisa:feature $ gh pr create --template "pull_request_template.md" (?:)(?\w[\w'-]*)(?(?:<<|<|«|\(|\[|\{)))(?:::|[\w':-]))+|[$@%&]+\*(?:(?!(?:)(?\w[\w'-]*)(?(?:<<|<|«|\(|\[|\{)))(?:::|[\w':-]))+)(?=(:['\w-]+(?:<<|<|«|\(|\[|\{).+?(?:>>|>|»|\)|\]|\}))?) # Download and run the Copilot CLI $ gh copilot # Run the Copilot CLI $ gh copilot -p "Summarize this week's commits" --allow-tool 'shell(git)' # Remove the Copilot CLI (if installed through gh) $ gh copilot --remove # Run the Copilot CLI help command $ gh copilot -- --help Upload asset files to a GitHub Release. To define a display label for an asset, append text starting with %[1]s#%[1]s after the file name. When using %[1]s--clobber%[1]s, existing assets are deleted before new assets are uploaded. If the upload fails, the original assets will be lost. Execute a test program to preview the prompter. Without an argument, all prompts will be run. Available prompt types: - select - multi-select - multi-select-with-search - input - password - confirm - auth-token - confirm-deletion - input-hostname - markdown-editor statusCheckRollup: commits(last: 1) { nodes { commit { statusCheckRollup { contexts { checkRunCount, checkRunCountsByState { state, count }, statusContextCount, statusContextCountsByState { state, count } } } } } } List the items in a project. If supported by the API host (github.com and GHES 3.20+), the --query option can be used to perform advanced search. For the full syntax, see: https://docs.github.com/en/issues/planning-and-tracking-with-projects/customizing-views-in-your-project/filtering-projects query ComparePullRequestBaseBranchWith($owner: String!, $repo: String!, $pullRequestNumber: Int!, $headRef: String!) { repository(owner: $owner, name: $repo) { pullRequest(number: $pullRequestNumber) { baseRef { compare (headRef: $headRef) { aheadBy, behindBy, status } } } } } # Use interactively $ gh extension create # Create a script-based extension $ gh extension create foobar # Create a Go extension $ gh extension create --precompiled=go foobar # Create a non-Go precompiled extension $ gh extension create --precompiled=other foobar comments(first: 100) { nodes { id, author{login,...on User{id,name}}, authorAssociation, body, createdAt, includesCreatedEdit, isMinimized, minimizedReason, reactionGroups{content,users{totalCount}}, url, viewerDidAuthor }, pageInfo{hasNextPage,endCursor}, totalCount } Delete codespaces based on selection criteria. All codespaces for the authenticated user can be deleted, as well as codespaces for a specific repository. Alternatively, only codespaces older than N days can be deleted. Organization administrators may delete any codespace billed to the organization. (?!(?:function|class|static|var|if|else|while|do|for|break|return|continue|extends|implements|import|switch|case|default|public|private|try|untyped|catch|new|this|throw|extern|enum|in|interface|cast|override|dynamic|typedef|package|inline|using|null|true|false|abstract)\b)(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+) Secrets can be set at the repository, or organization level for use in GitHub Actions or Dependabot. User, organization, and repository secrets can be set for use in GitHub Codespaces. Environment secrets can be set for use in GitHub Actions. Run %[1]sgh help secret set%[1]s to learn how to get started. (\.)((?!(?:function|class|static|var|if|else|while|do|for|break|return|continue|extends|implements|import|switch|case|default|public|private|try|untyped|catch|new|this|throw|extern|enum|in|interface|cast|override|dynamic|typedef|package|inline|using|null|true|false|abstract)\b)(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+))query RepositoryList(%s) { %s { login repositories(first: $perPage, after: $endCursor, ownerAffiliations: OWNER, orderBy: { field: PUSHED_AT, direction: DESC }) { nodes{ id name isTemplate defaultBranchRef { name } } totalCount pageInfo{hasNextPage,endCursor} } } } Get 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 List variables 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 Generate the autocompletion script for the fish shell. To load completions in your current shell session: %[1]s completion fish | source To load completions for every new session, execute once: %[1]s completion fish > ~/.config/fish/completions/%[1]s.fish You will need to start a new shell for this setup to take effect. Delete 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 query PullRequestForBranch($owner: String!, $repo: String!, $headRefName: String!, $states: [PullRequestState!]) { repository(owner: $owner, name: $repo) { pullRequests(headRefName: $headRefName, states: $states, first: 30, orderBy: { field: CREATED_AT, direction: DESC }) { nodes {%s} } defaultBranchRef { name } } } viewerCreated: search(query: $viewerQuery, type: ISSUE, first: $per_page) { totalCount: issueCount edges { node { ...prWithReviews } } } reviewRequested: search(query: $reviewerQuery, type: ISSUE, first: $per_page) { totalCount: issueCount edges { node { ...pr } } } } Clone a GitHub gist locally. A gist can be supplied as argument in either of the following formats: - by ID, e.g. %[1]s5b0e0062eb8e9654adad7bb1d81cc75f%[1]s - by URL, e.g. %[1]shttps://gist.github.com/OWNER/5b0e0062eb8e9654adad7bb1d81cc75f%[1]s Pass additional %[1]sgit clone%[1]s flags by listing them after %[1]s--%[1]s. # Sync local repository from remote parent $ gh repo sync # Sync local repository from remote parent on specific branch $ gh repo sync --branch v1 # Sync remote fork from its parent $ gh repo sync owner/cli-fork # Sync remote repository from another remote repository $ gh repo sync owner/repo --source owner2/repo2 GH_TOKEN, GITHUB_TOKEN (in order of precedence): an authentication token for %[1]sgithub.com%[1]s API requests. GH_ENTERPRISE_TOKEN, GITHUB_ENTERPRISE_TOKEN (in order of precedence): an authentication token for API requests to GitHub Enterprise. GH_HOST: make the request to a GitHub host other than %[1]sgithub.com%[1]s. # Approve the pull request of the current branch $ gh pr review --approve # Leave a review comment for the current branch $ gh pr review --comment -b "interesting" # Add a review for a specific pull request $ gh pr review 123 # Request changes on a specific pull request $ gh pr review 123 -r -b "needs more ASCII art" # Create a field in the current user's project "1" $ gh project field-create 1 --owner "@me" --name "new field" --data-type "text" # Create a field with three options to select from for owner monalisa $ gh project field-create 1 --owner monalisa --name "new field" --data-type "SINGLE_SELECT" --single-select-options "one,two,three" Execute an extension using the short name. For example, if the extension repository is %[1]sowner/gh-extension%[1]s, you should pass %[1]sextension%[1]s. You can use this command when the short name conflicts with a core gh command. All arguments after the extension name will be forwarded to the executable of the extension. View information about a GitHub ruleset. If no ID is provided, an interactive prompt will be used to choose the ruleset to view. Use the %[1]s--parents%[1]s flag to control whether rulesets configured at higher levels that also apply to the provided repository or organization should be returned. The default is %[1]strue%[1]s. Watch a run until it completes, showing its progress. By default, all steps are displayed. The %[1]s--compact%[1]s option can be used to only show the relevant/failed steps. This command does not support authenticating via fine grained PATs as it is not currently possible to create a PAT with the %[1]schecks:read%[1]s permission. # Select a codespace from a list of all codespaces you own $ gh cs view # View the details of a specific codespace $ gh cs view -c codespace-name-12345 # View the list of all available fields for a codespace $ gh cs view --json # View specific fields for a codespace $ gh cs view --json displayName,machineDisplayName,state # Download all artifacts generated by a workflow run $ gh run download # Download a specific artifact within a run $ gh run download -n # Download specific artifacts across all runs in a repository $ gh run download -n -n # Select artifacts to download interactively $ gh run download # View the Go gitignore template $ gh repo gitignore view Go # View the Python gitignore template $ gh repo gitignore view Python # Create a new .gitignore file using the Go template $ gh repo gitignore view Go > .gitignore # Create a new .gitignore file using the Python template $ gh repo gitignore view Python > .gitignore stateTextstateTagstateAttrNamestateAfterNamestateBeforeValuestateHTMLCmtstateRCDATAstateAttrstateURLstateSrcsetstateJSstateJSDqStrstateJSSqStrstateJSTmplLitstateJSRegexpstateJSBlockCmtstateJSLineCmtstateJSHTMLOpenCmtstateJSHTMLCloseCmtstateCSSstateCSSDqStrstateCSSSqStrstateCSSDqURLstateCSSSqURLstateCSSURLstateCSSBlockCmtstateCSSLineCmtstateErrorstateDead %[1]s Created directory %[2]s %[1]s Initialized git repository %[7]s Made initial commit %[1]s Set up extension scaffolding %[6]s %[2]s is ready for development! %[4]s %[5]s - run 'gh repo create' to share your extension with others For more information on writing extensions: %[3]s query IssueSearch($repo: String!, $owner: String!, $type: SearchType!, $limit: Int, $after: String, $query: String!) { repository(name: $repo, owner: $owner) { hasIssuesEnabled } search(type: $type, last: $limit, after: $after, query: $query) { issueCount nodes { ...issue } pageInfo { hasNextPage endCursor } } }This extension does not support the %[1]s architecture. I tried to install it on a %[1]s machine, and it failed due to the lack of an available binary. Would you be able to update the extension's build and release process to include the relevant binary? For more details, see . query LabelList($owner: String!, $repo: String!, $limit: Int!, $endCursor: String, $query: String, $orderBy: LabelOrder) { repository(owner: $owner, name: $repo) { labels(first: $limit, after: $endCursor, query: $query, orderBy: $orderBy) { totalCount, nodes { ...label } pageInfo { hasNextPage endCursor } } } } List repositories owned by a user or organization. Note that the list will only include repositories owned by the provided argument, and the %[1]s--fork%[1]s or %[1]s--source%[1]s flags will not traverse ownership boundaries. For example, when listing the forks in an organization, the output would not include those owned by individual users. query PullRequestForRun($owner: String!, $repo: String!, $headRefName: String!) { repository(owner: $owner, name: $repo) { pullRequests(headRefName: $headRefName, first: 1, orderBy: { field: CREATED_AT, direction: DESC }) { nodes { number headRepository { owner { login } name } } } } } # Verify an asset from the latest release $ gh release verify-asset ./dist/my-asset.zip # Verify an asset from a specific release tag $ gh release verify-asset v1.2.3 ./dist/my-asset.zip # Verify an asset from a specific release tag and output the attestation in JSON format $ gh release verify-asset v1.2.3 ./dist/my-asset.zip --format json # Install an extension from a remote repository hosted on GitHub $ gh extension install owner/gh-extension # Install an extension from a remote repository via full URL $ gh extension install https://my.ghes.com/owner/gh-extension # Install an extension from a local repository in the current working directory $ gh extension install . # Start interactive setup $ gh auth login # Open a browser to authenticate and copy one-time OAuth code to clipboard $ gh auth login --web --clipboard # Authenticate against github.com by reading the token from a file $ gh auth login --with-token < mytoken.txt # Authenticate with specific host $ gh auth login --hostname enterprise.internal Create an issue on GitHub. Adding an issue to projects requires authorization with the %[1]sproject%[1]s scope. To authorize, run %[1]sgh auth refresh -s project%[1]s. The %[1]s--assignee%[1]s flag supports the following special values: - %[1]s@me%[1]s: assign yourself - %[1]s@copilot%[1]s: assign Copilot (not supported on GitHub Enterprise Server) # Download all assets from a specific release $ gh release download v1.2.3 # Download only Debian packages for the latest release $ gh release download --pattern '*.deb' # Specify multiple file patterns $ gh release download -p '*.deb' -p '*.rpm' # Download the archive of the source code for a release $ gh release download v1.2.3 --archive=zip fragment repo on Repository { id name owner { login } hasIssuesEnabled description hasWikiEnabled viewerPermission defaultBranchRef { name } } query RepositoryInfo($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { ...repo parent { ...repo } mergeCommitAllowed rebaseMergeAllowed squashMergeAllowed } } # Link monalisa's project 1 to her repository "my_repo" $ gh project link 1 --owner monalisa --repo my_repo # Link monalisa's organization's project 1 to her team "my_team" $ gh project link 1 --owner my_organization --team my_team # Link monalisa's project 1 to the repository of current directory if neither --repo nor --team is specified $ gh project link 1 Autolinks link issues, pull requests, commit messages, and release descriptions to external third-party services. Autolinks require %[1]sadmin%[1]s role to view or manage. For more information, see $ gh issue create --title "I found a bug" --body "Nothing works" $ gh issue create --label "bug,help wanted" $ gh issue create --label bug --label "help wanted" $ gh issue create --assignee monalisa,hubot $ gh issue create --assignee "@me" $ gh issue create --assignee "@copilot" $ gh issue create --project "Roadmap" $ gh issue create --template "Bug Report" List secrets 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, Dependabot, or Codespaces within an organization - user: available to Codespaces for your user (?!(?:\$\s*[a-z]\b|\$(?!(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+))))(?!(?:function|class|static|var|if|else|while|do|for|break|return|continue|extends|implements|import|switch|case|default|public|private|try|untyped|catch|new|this|throw|extern|enum|in|interface|cast|override|dynamic|typedef|package|inline|using|null|true|false|abstract)\b)(?:_*[a-z]\w*|_+[0-9]\w*|_*[A-Z]\w*|_+|\$\w+) Delete a secret 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, Dependabot, or Codespaces within an organization - user: available to Codespaces for your user {{- if .ShowHelp }}{{- color .Config.Icons.Help.Format }}{{ .Config.Icons.Help.Text }} {{ .Help }}{{color "reset"}}{{"\n"}}{{end}} {{- color .Config.Icons.Question.Format }}{{ .Config.Icons.Question.Text }} {{color "reset"}} {{- color "default+hb"}}{{ .Message }} {{color "reset"}} {{- if and .Help (not .ShowHelp)}}{{color "cyan"}}[{{ .Config.HelpInput }} for help]{{color "reset"}} {{end}} query PullRequestStatus($owner: String!, $repo: String!, $number: Int!, $viewerQuery: String!, $reviewerQuery: String!, $per_page: Int = 10) { repository(owner: $owner, name: $repo) { defaultBranchRef { name } pullRequest(number: $number) { ...prWithReviews baseRef { branchProtectionRule { requiredApprovingReviewCount } } } } Update a pull request branch with latest changes of the base branch. Without an argument, the pull request that belongs to the current branch is selected. The default behavior is to update with a merge commit (i.e., merging the base branch into the PR's branch). To reconcile the changes with rebasing on top of the base branch, the %[1]s--rebase%[1]s option should be provided. # Unlink monalisa's project 1 from her repository "my_repo" $ gh project unlink 1 --owner monalisa --repo my_repo # Unlink monalisa's organization's project 1 from her team "my_team" $ gh project unlink 1 --owner my_organization --team my_team # Unlink monalisa's project 1 from the repository of current directory if neither --repo nor --team is specified $ gh project unlink 1 # Download attestations for a local artifact linked with an organization $ gh attestation download example.bin -o github # Download attestations for a local artifact linked with a repository $ gh attestation download example.bin -R github/example # Download attestations for an OCI image linked with an organization $ gh attestation download oci://example.com/foo/bar:latest -o github # View the MIT license from SPDX ID $ gh repo license view MIT # View the MIT license from license key $ gh repo license view mit # View the GNU AGPL-3.0 license from SPDX ID $ gh repo license view AGPL-3.0 # View the GNU AGPL-3.0 license from license key $ gh repo license view agpl-3.0 # Create a LICENSE.md with the MIT license $ gh repo license view MIT > LICENSE.md # Open the GitHub Accessibility site in your browser $ gh accessibility --web # Display color using customizable, 4-bit accessible colors $ gh config set accessible_colors enabled # Use input prompts without redrawing the screen $ gh config set accessible_prompter enabled # Disable motion-based spinners for progress indicators in favor of text $ gh config set spinner disabled # Create a repository interactively $ gh repo create # Create a new remote repository and clone it locally $ gh repo create my-project --public --clone # Create a new remote repository in a different organization $ gh repo create my-org/my-project --public # Create a remote repository from the current directory $ gh repo create my-project --private --source=. --remote=upstream # List your most recent agent tasks $ gh agent-task list # Create a new agent task on the current repository $ gh agent-task create "Improve the performance of the data processing pipeline" # View details about agent tasks associated with a pull request $ gh agent-task view 123 # View details about a specific agent task $ gh agent-task view 12345abc-12345-12345-12345-12345abc Show CI status for a single pull request. Without an argument, the pull request that belongs to the current branch is selected. When the %[1]s--json%[1]s flag is used, it includes a %[1]sbucket%[1]s field, which categorizes the %[1]sstate%[1]s field into %[1]spass%[1]s, %[1]sfail%[1]s, %[1]spending%[1]s, %[1]sskipping%[1]s, or %[1]scancel%[1]s. Additional exit codes: 8: Checks pending Search for commits on GitHub. The command supports constructing queries using the GitHub search syntax, using the parameter and qualifier flags, or a combination of the two. GitHub search syntax is documented at: For more information on handling search queries containing a hyphen, run %[1]sgh search --help%[1]s. This command sets the default remote repository to use when querying the GitHub API for the locally cloned repository. gh uses the default repository for things like: - viewing and creating pull requests - viewing and creating issues - viewing and creating releases - working with GitHub Actions ### NOTE: gh does not use the default repository for managing repository and environment secrets. &in_toto_attestation/v1/statement.proto