Pular para o conteúdo principal

GitHub CLI

Intalação

Installing gh on Windows

Zip

gh --version

WinGet

WinGet is a command line tool enabling users to discover, install, upgrade, remove and configure applications on Windows 10, Windows 11, and Windows Server 2025 computers. This tool is the client interface to the Windows Package Manager service.

winget install --id GitHub.cli
winget upgrade --id GitHub.cli

winget.run

GitHub CLI manual

Display or change configuration settings

gh config --help
Display or change configuration settings for gh.

Current respected settings:
- `git_protocol`: the protocol to use for git clone and push operations `{https | ssh}` (default `https`)
- `editor`: the text editor program to use for authoring text
- `prompt`: toggle interactive prompting in the terminal `{enabled | disabled}` (default `enabled`)
- `prefer_editor_prompt`: toggle preference for editor-based interactive prompting in the terminal `{enabled | disabled}` (default `disabled`)
- `pager`: the terminal pager program to send standard output to
- `http_unix_socket`: the path to a Unix socket through which to make an HTTP connection
- `browser`: the web browser to use for opening URLs
- `color_labels`: whether to display labels using their RGB hex color codes in terminals that support truecolor `{enabled | disabled}` (default `disabled`)
- `accessible_colors`: whether customizable, 4-bit accessible colors should be used `{enabled | disabled}` (default `disabled`)
- `accessible_prompter`: whether an accessible prompter should be used `{enabled | disabled}` (default `disabled`)
- `spinner`: whether to use a animated spinner as a progress indicator `{enabled | disabled}` (default `enabled`)

USAGE
gh config <command> [flags]

AVAILABLE COMMANDS
clear-cache: Clear the cli cache
get: Print the value of a given configuration key
list: Print a list of configuration keys and values
set: Update configuration with a value for the given key

INHERITED FLAGS
--help Show help for command

LEARN MORE
Use `gh <command> <subcommand> --help` for more information about a command.
Read the manual at https://cli.github.com/manual
Learn about exit codes using `gh help exit-codes`
Learn about accessibility experiences using `gh help accessibility`
gh config set editor "code --wait"
gh config set browser ""
gh config get browser

Authenticate gh and git with GitHub

gh auth --help
Authenticate gh and git with GitHub

USAGE
gh auth <command> [flags]

AVAILABLE COMMANDS
login: Log in to a GitHub account
logout: Log out of a GitHub account
refresh: Refresh stored authentication credentials
setup-git: Setup git with GitHub CLI
status: Display active account and authentication state on each known GitHub host
switch: Switch active GitHub account
token: Print the authentication token gh uses for a hostname and account

Log in to a GitHub account

gh auth login

Log out of a GitHub account

gh auth logout

Display active account and authentication state on each known GitHub host

gh auth status

Work with GitHub organizations.

List organizations for the authenticated user.

gh org list
Work with GitHub organizations.

USAGE
gh org <command> [flags]

GENERAL COMMANDS
list: List organizations for the authenticated user.

INHERITED FLAGS
--help Show help for command

EXAMPLES
$ gh org list

Work with GitHub repositories.

gh repo create --help
Usage:  gh repo create [<name>] [flags]

Flags:
--add-readme Add a README file to the new repository
-c, --clone Clone the new repository to the current directory
-d, --description string Description of the repository
--disable-issues Disable issues in the new repository
--disable-wiki Disable wiki in the new repository
-g, --gitignore string Specify a gitignore template for the repository
-h, --homepage URL Repository home page URL
--include-all-branches Include all branches from template repository
--internal Make the new repository internal
-l, --license string Specify an Open Source License for the repository
--private Make the new repository private
--public Make the new repository public
--push Push local commits to the new repository
-r, --remote string Specify remote name for the new repository
-s, --source string Specify path to local repository to use as source
-t, --team name The name of the organization team to be granted access
-p, --template repository Make the new repository based on a template repository
EXAMPLES
# 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
gh repo create ELT73A-S22-2025-2-X/LAB00 --public -c -l mit --add-readme -g C
gh repo view ELT73A-S22-2025-2-X/LAB00 --web
gh repo delete ELT73A-S22-2025-2-X/LAB00x --yes
gh repo create ELT73A-S22-2025-2-X/LAB00c --public -c -l mit --add-readme -g C
gh repo view ELT73A-S22-2025-2-X/LAB00c --web
gh repo create ELT73A-S22-2025-2-X/LAB00 --public --template ELT73A-LAB-TPL/LAB00

Cria repo de template, clona e abre no VScode

gh repo create ELT73A-S22-2025-2-X/LAB00h --public -p ELT73A-LAB-TPL/LAB00 -c
cd LAB00y
code .

Crie um novo repositório com base em um template:

gh repo create ELT73A-S22-2025-2-X/LAB00-tmp --public --template ELT73A-LAB-TPL/LAB00
gh repo create ELT73A-S22-2025-2-X/LAB00-tmp --private --template ELT73A-LAB-TPL/LAB00

gh repo clone ELT73A-2025-1-X/my-new-repo

gh repo delete ELT73A-S22-2025-2-X/LAB00x --yes

Abra o repositório no Navegador Web:

gh repo view ELT73A-LAB-TPL/LAB00 --web
gh repo create ELT73A-S22-2025-2-X/LAB00x
gh repo list ELT73A-S22-2025-2-X
gh auth refresh -h github.com -s delete_repo

License

For more information, see: http://choosealicense.com/licenses/

gh repo license list
LICENSE KEYSPDX IDLICENSE NAME
agpl-3.0AGPL-3.0GNU Affero General Public License v3.0
apache-2.0Apache-2.0Apache License 2.0
bsd-2-clauseBSD-2-ClauseBSD 2-Clause "Simplified" License
bsd-3-clauseBSD-3-ClauseBSD 3-Clause "New" or "Revised" License
bsl-1.0BSL-1.0Boost Software License 1.0
cc0-1.0CC0-1.0Creative Commons Zero v1.0 Universal
epl-2.0EPL-2.0Eclipse Public License 2.0
gpl-2.0GPL-2.0GNU General Public License v2.0
gpl-3.0GPL-3.0GNU General Public License v3.0
lgpl-2.1LGPL-2.1GNU Lesser General Public License v2.1
mitMITMIT License
mpl-2.0MPL-2.0Mozilla Public License 2.0
unlicenseUnlicenseThe Unlicense
gh repo license --help
View a specific repository license by license key or SPDX ID.

Run `gh repo license list` to see available commonly used licenses.
For even more licenses, visit <https://choosealicense.com/appendix>.

USAGE
gh repo license view {<license-key> | <spdx-id>} [flags]

FLAGS
-w, --web Open https://choosealicense.com/ in the browser

INHERITED FLAGS
--help Show help for command

EXAMPLES
# 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