You know how painful it is to switch from terminal to browser, then again to the terminal while working with git repositories right? Then worry not, because GitHub CLI brings GitHub to your terminal.
GitHub has finally introduced its own command-line tool that brings pull requests, issues, and other GitHub concepts to the terminal next to where you are already working with git and your code. To quote GitHub it "reduces context switching, helps you focus, and enables you to more easily script and create your own workflows". Pretty cool right?
This post explains the installation and the setting-up of the GitHub CLI, hereby referred to as 'gh'.
gh can be installed on Windows using scoop or chocolatey package managers.
scoop bucket add github-gh https://github.com/cli/scoop-gh.git scoop install gh
choco install gh
macOS users can use either Homebrew or MacPorts to install gh.
brew install gh
sudo port install gh
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
sudo dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo sudo dnf install gh
sudo pacman -S github-cli
After the installation, running any command will prompt you to login to GitHub.
Run 'gh auth login' to authenticate your GitHub account. It'll ask you to select the account type, either a normal account or an enterprise one. I'll select the normal account.
Then it'll ask you to select your preferred authentication method. You can choose to authenticate using your browser or using the GitHub authentication token. I'll select the browser method.
Then it'll display a one-time code, you should copy it or write it down.
And then pressing enter will open the browser. You should enter the one-time code here.
Then click on "Authorize github" to complete the authentication. You can safely close the browser now.
Now it'll ask you to select the default git protocol. You can select HTTPS or SSH. I'll be selecting SSH because I've already made an SSH key, and it's easy cloning and pushing to the repo using SSH.
Aaaand that's it. You've successfully installed and set up the GitHub CLI.
I'm also planning a post explaining all the gh commands and how to use it, so be on the lookout for that.