LinuxCommandLibrary

gh-repo

Manage GitHub repositories from the command line

TLDR

Create a new repository (if the repository name is not set, the default name will be the name of the current directory)

$ gh repo create [name]
copy

Clone a repository
$ gh repo clone [owner]/[repository]
copy

Fork and clone a repository
$ gh repo fork [owner]/[repository] --clone
copy

View a repository in the default web browser
$ gh repo view [repository] --web
copy

List repositories owned by a specific user or organization (if the owner is not set, the default owner will be the currently logged in user)
$ gh repo list [owner]
copy

List only non-forks repositories and limit the number of repositories to list (default: 30)
$ gh repo list [owner] --source -L [limit]
copy

List repositories with a specific primary coding language
$ gh repo list [owner] --language [language_name]
copy

SYNOPSIS

gh repo {browse | clone | create | delete | edit | fork | list | rename | sync | view} [flags]

PARAMETERS

browse
    Open a repository in the browser.

clone
    Clone a repository locally.

create
    Create a new repository.

delete
    Delete a repository.

edit
    Edit repository settings.

fork
    Fork a repository.

list
    List repositories owned by a user or organization.

rename
    Rename a repository.

sync
    Sync a forked repository with its upstream.

view
    View a repository's details.

DESCRIPTION

The `gh-repo` command provides a convenient way to interact with GitHub repositories directly from the command line using the GitHub CLI (`gh`). It allows users to perform various actions, such as opening a repository in a web browser, cloning it locally, viewing its details, and more. This tool enhances productivity by reducing the need to switch between the terminal and a web browser for common GitHub tasks. It provides a simple, efficient, and integrated workflow for developers and users who frequently interact with GitHub repositories. The command utilizes the GitHub API under the hood to retrieve information and execute actions, ensuring that users have access to the latest features and data available on GitHub.

CAVEATS

Requires the GitHub CLI (`gh`) to be installed and authenticated. Some actions might require specific permissions on the target repository.

EXAMPLES

Opening a repository in the browser:
gh repo browse owner/repo-name

Cloning a repository:
gh repo clone owner/repo-name

AUTHENTICATION

The gh tool handles authentication through the gh auth command. Ensure you are properly authenticated before using gh repo.

HISTORY

The `gh-repo` command is part of the GitHub CLI, which was developed by GitHub to provide a more streamlined command-line interface for interacting with GitHub. It was created to address the limitations of using `git` alone for managing GitHub repositories, and to make it easier for developers to automate common tasks and workflows.

SEE ALSO

gh(1), git(1)

Copied to clipboard