GitHub CLI : All you need to know
GitHub announced the beta of GitHub CLI and GitHub CLI 1.0 is now available.
GitHub CLI basically brings GitHub to your terminal. With GitHub CLI, developers can check the status of GitHub issues and pull requests, search for a specific issue or PR, create/fork a repo, or create new issues and pull requests right from the command line.
It reduces context switching, helps you focus, and enables you to more easily script and create your own workflows.
GitHub CLI is available across all platforms, MacOS, Windows and various Linux.
What will be covered in this blog :
- How to download and Authenticate
- Managing GitHub Repositories using GitHub CLI
- Working with Pull Requests using GitHub CLI
- Managing GitHub Issues using GitHub CLI
- Working with GitHub gist using GitHub CLI
- GitHub alias using GitHub CLI
How to download it?
To install GitHub CLI on your machine, you can refer to the installation guide found on GitHub. To download click the Link Click the link to navigate to the guide.
Authentication
After a successful installation, you need to authenticate your Github account.
To authenticate your account you need to use the following command.
gh auth login
Managing GitHub Repositories using GitHub CLI
1. Create GitHub Repositories
To create a new GitHub repository use the following command.
gh repo create [<name>] [flags]
2. View GitHub Repositories
Display the description and the README of a GitHub repository. With no argument, the repository for the current directory is displayed.
gh repo view [<repository>] [flags]
3. Fork GitHub Repositories
Lets fork of a repository with GitHub CLI.
If you don’t provide any argument, creates a fork of the current repository. Otherwise, forks the specified repository.
gh repo fork [<repository>] [flags]
Working with Pull Requests using GitHub CLI
1. Create Pull Request
You can use the following command to create a new pull request directly from the command line.
gh pr create --title "Pull request title" --body "Pull request body"
2. List Pull Requests
gh pr list
3. Check Pull Request Status
If you wish to check the status the PRs you created earlier, you can use the status command
to list them at the terminal
gh pr status
4. View Pull Request
You can open the PR from the command line using the view command.
gh pr view [<number> | <url> | <branch>] [flags]
5. Checkout Pull Request
You can checkout a Pull Request in GitHub CLI using the following command.
gh pr checkout {<number> | <url> | <branch>} [flags]
Managing GitHub Issues using GitHub CLI
1. List Issues With GitHub CLI
gh issue list
2. Checking Issue Status With GitHub CLI
You can use the following command to list them at the terminal.
gh issue status
3. Viewing Issues With GitHub CLI
You can open the issue from the command line using the following command.
gh issue view {<number> | <url>} [flags]
4. Creating Issues With GitHub CLI
You can create an issue with the help of the following command.
gh issue create --title "Issue title" --body "Issue body"
Working with GitHub gist using GitHub CLI
1. Create gist with GitHub CLI
Create a new GitHub gist with given contents. Gists can be created from one or multiple files. Alternatively, pass “-“ as file name to read from standard input.
By default, gists are private; use ‘–public’ to make publicly listed ones.
gh gist create [<filename>... | -] [flags]
2. List gist with GitHub CLI
You can list your gists with GitHub CLI using the following command.
gh gist list [flags]
3. View gist with GitHub CLI
You can view your gists with GitHub CLI using the following command.
gh gist view {<gist id> | <gist url>} [flags]
Working with GitHub alias using GitHub CLI
You can print out all of the aliases gh
is configured to use using the following command.
gh alias list [flags]
I hope this helped you. Thank You and have a nice day.