GitHub CLI is a command-line tool developed by GitHub that allows you to interact with GitHub directly from your terminal. It provides a more convenient way to manage repositories, issues, pull requests, and other GitHub features without using the web interface. The CLI makes it easier to perform various tasks, automate workflows, and integrate with other tools.
Here are some popular GitHub CLI commands:
gh repo clone <repository>: Clone a GitHub repository to your local machine. Replace
<repository>with the repository’s URL or its shorthand (e.g.,
gh pr list: List all pull requests in the current repository. You can filter by status (open, closed, merged), author, assignee, or base branch.
gh pr create: Create a new pull request. This command opens an interactive prompt to fill in the required fields, like the base branch and head branch. You can also use flags like
-headto specify the details directly.
gh pr view <pull_request_id>: View the details of a pull request, including the title, description, author, and status. Replace
<pull_request_id>with the pull request number.
gh pr checkout <pull_request_id>: Check out a pull request locally. This command creates a new branch and sets it to the commit of the specified pull request.
gh repo view -w: Open the repository in the web browser
gh issue create: Create a new issue in the current repository. Similar to
gh pr create, this command opens an interactive prompt to fill in the required fields. You can use flags like
-bodyto specify the details directly.
gh issue list: List all issues in the current repository. You can filter by status (open, closed), author, assignee, or labels.
gh issue view <issue_id>: View the details of an issue, including the title, description, author, and status. Replace
<issue_id>with the issue number.
gh repo create: Create a new repository on GitHub. This command opens an interactive prompt to fill in the required fields, like the repository name and visibility. You can use flags like
-privateto specify the details directly.
gh auth login: Authenticate the GitHub CLI with your GitHub account. This command opens an interactive prompt to choose the authentication method (GitHub.com or GitHub Enterprise Server) and the preferred browser or token method.
These are just a few examples of the many commands available in the GitHub CLI. You can find more information and examples in the official GitHub CLI documentation: https://cli.github.com/manual/