Making git operations easy using GitHub CLI

Tauqeer Ahmad
4 min readJun 22, 2022

TYPE TYPE TPYE!

*pure mechanical keyboard sound buzzing* and wait! You have to leave your keyboard environment and get on GitHub.com just create a repository.

Interrupting NO!!? Getting back to the environment you left will be uneasy to adapt again.

To tackle all these developer behavior GitHub has introduced its own CLI to compute and as well to save the time of a developer.

GitHub CLI

Let’s get on the main page of GitHub CLI and read out the directory being presented as the context.

Ref : https://github.com/cli/cli

As said GitHub officially states some facts of CLI the faster adaptation of developer environment.

Some of the installation note. Note here that Fedora 36 is being used which is based on RHEL and uses RPM package manager.

For RHEL based setup : sudo dnf install 'dnf-command(config-manager)'

Official Installation Directory : https://github.com/cli/cli/blob/trunk/docs/install_linux.md

sudo dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
sudo dnf install gh

Let’s check the installation of our CLI.

gh --version 

Use the command given above to verify it has been installed as well the specification of version also.

Now let’s do some crazy things using CLI, which will save us from a lot of movements.

HERE WE GO !!

POV: About to initialize a project, but tideous to move to remote and create a repository. Here it is how to deal.

gh repo create [<name>] [flags]

Here we’re simply passing create function which help us to create a repository over remote.

Flags are also required while working with repo creation. — public flag defines that repository is public.

With all these things a twist has been created, — clone flag is also used typically making us an ease to have that live repo as local one.

git remote -v 

As shown, the repository has been set as origin. Now moving ahead with our development and directly using git on our system.

POV: You’re about to clone a repo or a project, so GitHub CLI will help you in this.

gh repo fork AnshumanFauzdar/Microsoft365 --cloneSyntax: 
gh repo fork <organization>/<organization's repo> --clone

BOOM! Now it’s is in your local system, start contributing into it. That’s all happened with just a collection of commands.

NOTE: ORGANIZATION/REPO term is being used for forking.

POV: Now we’re into performance and contribution, so from the process of branching and all, we’re ready to create a PULL REQUEST.

So GitHub CLI there for you PR creation.

Basic method for PR Creation

Using CLI for the Pull Request:

Pull Request using GitHub CLI
Pull Request using GitHub CLI

Pull Request Merged on the the Pull Request Page:

New changes being reflected after merging the PR:

Fun fact: All the things happened from the CLI, just using some commands and keyboard.

So till here, we’ve learnt about Setting up of GitHub CLI, it’s keypoints, creating a repo, cloning and forking a repo and significantly opening and merging a pull request.

Well, everything is not covered yet as this is just a glimpse of GitHub CLI and a helping hand towards a beginning of new interface.

More to learn about GitHub CLI: https://cli.github.com/manual/

Beginner in the state of Git and GitHub? Yeah, I got you, go for this embedded blog: Let’s begin with Git and GitHub

Happy journey, keep exploring and keep updated!!

--

--

Tauqeer Ahmad

Hola everyone ! Currently a tech evangelist and learning lad making superb content on whatever I’ve learnt.