Github CLI – Simplify life for developers

Tram Ho

1. Introduction

Teamwork is a must for a developer, and the best tool for optimizing cooping is Github. The thing is, after I switched to a new operating system, cloning projects was really tough for me because I had to constantly open the github to copy the remote link, then proceed to clone and setup.

A year ago, Github released Github CLI tool which is quite interesting and convenient for developers to solve workflow problems like in my example above. The main functions can be summed up to bring your Github from the web to a terminal environment.

Image introduces Github CLI

2. How to install

Home page Github CLI

As Microsoft’s darling, the tutorials are very clear. You can install based on instructions from the home page. https://github.com/cli/cli#installation

3. Features

Once installed, let’s try out a few basic functions. First, let us use the command:

The functions of Github CLI will be fully listed. First thing we need to do is Login to your Github account with the command:

There will be 2 options that are login with the web or paste the authentication token in (about the authentication token, Github is now gradually switching to using this method for tasks that need to be linked to the authentication token account ).


In this article I will introduce the feature that people use the most in Github that is interacting with the repo through the COMMAND gh repo :

The first function is to create the repo gh repo create [<name>] , with just one command, we have passed a lot of stuff while creating the repo on the web.

github cli create repo

And of course it will replace us with the setup of the github repo locally

github cli congfig git remote


The next function is to clone repo back with the command gh repo clone [<url>] However, normally we only clone the individual repo when switching the working environment, but Github CLI does not support the gh repo list command. (still in issue view).

After the research process, I found a very good tip for mislav users. We’ll open up the ~ / .config / gh / config.yml file and add this config.

The purpose is to use the command gh api and the jq library (remember to install it) to be able to handle the GraphQL responses returned by Github.

After configuring is done, we can use the command gh repos [<username>] to list all repos of any user.

Github list repo

Other functions such as view or fork are similar, you can use the command gh repo --help which will have full documentation instructions (pet has another).

4. Summary

Today I introduced the Github CLI, a great tool for developers. Hope you will apply it and optimize the workflow for better code. Happy New Year.

Share the news now

Source : Viblo