Github just released a new command line tool called the GitHub CLI. It brings pull requests, issues, and other GitHub concepts to the terminal next to where you are already working.
GitHub CLI ??
gh
is GitHub on the command line. It brings pull requests, issues, and other GitHub concepts to the terminal next to where you are already working.GitHub CLI is available for download on Linux, MacOS, Windows machines
Installation
For MacoS, gh
is available via Homebrew and MacPorts.
brew install gh
sudo port install gh
For Windows, gh
is available via scoop, chocolatey and as downloadable MSI
- scoop
scoop bucket add github-gh https://github.com/cli/scoop-gh.git
scoop install gh
- chocolatey
choco install gh
For Linux
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0
sudo apt-add-repository https://cli.github.com/packages
sudo apt update
sudo apt install gh
Authentication:
Use below command to authenticate with your GitHub account. gh
will respect tokens set using GITHUB_TOKEN.
gh auth login
For GitHub Enterprise instance
gh auth login --hostname <hostname>
You will be prompted to either authenticate using your browser, or to paste a token.
View Authentication status
gh auth status [flags]
Now we have Successfully installed the GitHub CLI. lets clone a repo and raise a PR
gh repo clone @username/@reponame
By this time, GitHub will ask to authenticate.Once Authenticated navigate to cloned repo
cd @reponame
Creating a new branch ,create a file in this branch and push it
git checkout -b new_branch
touch test.js
echo "Testing" >> test.js
git push origin new_branch
To create a PR
gh pr create
Answering simple questions to above command creates a PR
To know all pull requests
gh pr checkout {<pull request number> | <url> | <branch>} [flags]
To view Diff
gh pr diff
To merge a PR
gh pr merge
To know if all test cases are passing
gh pr checks
To know open issues assigned to you.
gh issue status
By using below command , you can see any issues assigned to you or any issues that mentioned you
To know all issues
gh issue list
gh issue list --state open
gh issue list --state closed
By using below command , you can see all issues
To create a PR
gh pr create
Answering simple questions to above command creates a PR
How to manage Aliases with github cli
A alias is essentially nothing more than a keyboard shortcut, an abbreviation, a means of avoiding typing a long command sequence
Creating an Alias
gh alias set
Share your alias with gist
gh alias list | gh gist create
To access the GitHub API directly
gh api
Top comments (0)