Making git operations easy using GitHub CLI

Making git operations easy using GitHub CLI

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.

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 notes. 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 as the specification of the 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 tedious to move to remote and create a repository. Here is how to deal.

gh repo create [<name>] [flags]

Here we’re simply passing create a function that helps us to create a repository over remote.

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

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

git remote -v

As shown, the repository has been set as the 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 with this.

gh repo fork AnshumanFauzdar/Microsoft365 --clone

SYNTAX:

gh repo fork <organization's repo> --clone

BOOM! Now it is in your local system, start contributing to 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 is there for your PR creation.

Using CLI for the Pull Request:

Pull Request using GitHub CLI

Pull Request using GitHub CLI:

Pull Request Merged on 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 through the keyboard.

So here, we’ve learned about Setting up GitHub CLI, its key points, 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 the beginning of the new interface.

More to learn about GitHub CLI: 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!!