So GitHub has a CLI - let's take a look

Published Sep 23 2021 12:01 AM 2,360 Views
Microsoft

Did you know there is a command line interface available for GitHub interactions?  If you are working within a command line and need to interact with GitHub it means less context switching.  The GitHub CLI tool was released in September 2020 and is now on version 2.0 of the tool.

 

The GitHub CLI tool Is available for install on Windows, macOS and Linux operating systems.

 

From within the GitHub CLI tool, you can interact with a lot of GitHub functions.   You can manage gists, issues, pull requests (pr), repositories, GitHub secrets, and GitHub Actions to list a few of the core commands.

 

Let’s look at those commands in action.

 

Create and view issues

If you have cloned a GitHub repository (repo) to your local machine to work on, for example I have a copy of my GitHub profile repo on my machine. If I am working inside Windows Terminal I can check if there are any issues listed against that repo.

 

GitHub CLI Issue commandGitHub CLI Issue command

 

I can also create an issue within the terminal.

 

GitHub CLI Issue command in actionGitHub CLI Issue command in action

 

The work within the terminal can then be seen inside a browser. The flags and text that I put within the issue has been transferred across, as you would expect.

 

GitHub issue on the webGitHub issue on the web

 

 

You can also close the issue or edit it or even delete the issue, depending on the best way to manage that issue.

 

Track a Pull Request

You don’t have to always have the GitHub repo cloned to your local computer to interact with it via the CLI tool.

 

If you are tracking a pull request (PR) within a repository and know the URL you can use the GitHub CLI to view or interact with it.

 

GitHub CLI PR commandGitHub CLI PR command

 

Viewing the PR is something you can do, as demonstrated in the above picture but you can also look at closing, commenting, editing, merging, etc that PR into the repository.  For some people using the web graphical user interface will be much easier but for others this CLI command tool will be better suited.

 

GitHub Gist

I’m a big fan of using the GitHghub gist feature for a few reasons. And I’m able to view and edit them from the GitHub CLI as well.  I can list my gist’s and then edit them.

 

When I issue the gh gist edit <gist ID> command it will open up the gist within Notepad for me to edit and I can then save the changes and they are locked in.  Such an easy way of editing a gist or viewing it.

 

GitHub CLI gist commandGitHub CLI gist command

 

There is so many possibilities with this tool, install GitHub CLI today and leave me a comment below with what use cases it helps you with.

%3CLINGO-SUB%20id%3D%22lingo-sub-2728010%22%20slang%3D%22en-US%22%3ESo%20GitHub%20has%20a%20CLI%20-%20let's%20take%20a%20look%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2728010%22%20slang%3D%22en-US%22%3E%3CP%3EDid%20you%20know%20there%20is%20a%20command%20line%20interface%20available%20for%20GitHub%20interactions%3F%26nbsp%3B%20If%20you%20are%20working%20within%20a%20command%20line%20and%20need%20to%20interact%20with%20GitHub%20it%20means%20less%20context%20switching.%26nbsp%3B%20The%20GitHub%20CLI%20tool%20was%20released%20in%20September%202020%20and%20is%20now%20on%20version%202.0%20of%20the%20tool.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20GitHub%20CLI%20tool%20Is%20available%20for%20install%20on%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fcli%2Fcli%23installation%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EWindows%2C%20macOS%20and%20Linux%20operating%20systems%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFrom%20within%20the%20GitHub%20CLI%20tool%2C%20you%20can%20interact%20with%20a%20lot%20of%20GitHub%20functions.%26nbsp%3B%26nbsp%3B%20You%20can%20manage%20gists%2C%20issues%2C%20pull%20requests%20(pr)%2C%20repositories%2C%20GitHub%20secrets%2C%20and%20GitHub%20Actions%20to%20list%20a%20few%20of%20the%20core%20commands.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELet%E2%80%99s%20look%20at%20those%20commands%20in%20action.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ECreate%20and%20view%20issues%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EIf%20you%20have%20cloned%20a%20GitHub%20repository%20(repo)%20to%20your%20local%20machine%20to%20work%20on%2C%20for%20example%20I%20have%20a%20copy%20of%20my%20%3CA%20href%3D%22http%3A%2F%2Fgithub.com%2Fweeyin83%2Fweeyin83.github.io%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EGitHub%20profile%20repo%3C%2FA%3E%20on%20my%20machine.%20If%20I%20am%20working%20inside%20Windows%20Terminal%20I%20can%20check%20if%20there%20are%20any%20issues%20listed%20against%20that%20repo.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22ghcli1.PNG%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F308481i9689F900D141D319%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22ghcli1.PNG%22%20alt%3D%22GitHub%20CLI%20Issue%20command%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EGitHub%20CLI%20Issue%20command%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20can%20also%20create%20an%20issue%20within%20the%20terminal.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22ghcli2.gif%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F308482i4B426237B7A21FE9%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22ghcli2.gif%22%20alt%3D%22GitHub%20CLI%20Issue%20command%20in%20action%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EGitHub%20CLI%20Issue%20command%20in%20action%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20work%20within%20the%20terminal%20can%20then%20be%20seen%20inside%20a%20browser.%20The%20flags%20and%20text%20that%20I%20put%20within%20the%20issue%20has%20been%20transferred%20across%2C%20as%20you%20would%20expect.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22ghcli3.PNG%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F308483iCEC29099336D9EA5%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22ghcli3.PNG%22%20alt%3D%22GitHub%20issue%20on%20the%20web%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EGitHub%20issue%20on%20the%20web%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20also%20close%20the%20issue%20or%20edit%20it%20or%20even%20delete%20the%20issue%2C%20depending%20on%20the%20best%20way%20to%20manage%20that%20issue.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ETrack%20a%20Pull%20Request%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EYou%20don%E2%80%99t%20have%20to%20always%20have%20the%20GitHub%20repo%20cloned%20to%20your%20local%20computer%20to%20interact%20with%20it%20via%20the%20CLI%20tool.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20are%20tracking%20a%20pull%20request%20(PR)%20within%20a%20repository%20and%20know%20the%20URL%20you%20can%20use%20the%20GitHub%20CLI%20to%20view%20or%20interact%20with%20it.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22ghcli4.PNG%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F308485iD381B2E0C297233C%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22ghcli4.PNG%22%20alt%3D%22GitHub%20CLI%20PR%20command%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EGitHub%20CLI%20PR%20command%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EViewing%20the%20PR%20is%20something%20you%20can%20do%2C%20as%20demonstrated%20in%20the%20above%20picture%20but%20you%20can%20also%20look%20at%20closing%2C%20commenting%2C%20editing%2C%20merging%2C%20etc%20that%20PR%20into%20the%20repository.%26nbsp%3B%20For%20some%20people%20using%20the%20web%20graphical%20user%20interface%20will%20be%20much%20easier%20but%20for%20others%20this%20CLI%20command%20tool%20will%20be%20better%20suited.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EGitHub%20Gist%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EI%E2%80%99m%20a%20big%20fan%20of%20using%20the%20%3CA%20href%3D%22https%3A%2F%2Fwww.techielass.com%2Fusing-github-gists%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EGitHghub%20gist%20feature%3C%2FA%3E%20for%20a%20few%20reasons.%20And%20I%E2%80%99m%20able%20to%20view%20and%20edit%20them%20from%20the%20GitHub%20CLI%20as%20well.%26nbsp%3B%20I%20can%20list%20my%20gist%E2%80%99s%20and%20then%20edit%20them.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20I%20issue%20the%20%3CSTRONG%3Egh%20gist%20edit%20%3CGIST%20id%3D%22%22%3E%20%3C%2FGIST%3E%3C%2FSTRONG%3Ecommand%20it%20will%20open%20up%20the%20gist%20within%20Notepad%20for%20me%20to%20edit%20and%20I%20can%20then%20save%20the%20changes%20and%20they%20are%20locked%20in.%26nbsp%3B%20Such%20an%20easy%20way%20of%20editing%20a%20gist%20or%20viewing%20it.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22ghcli6.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F308486i723C04EC222DE74F%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22ghcli6.png%22%20alt%3D%22GitHub%20CLI%20gist%20command%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EGitHub%20CLI%20gist%20command%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThere%20is%20so%20many%20possibilities%20with%20this%20tool%2C%20install%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcli.github.com%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EGitHub%20CLI%3C%2FA%3E%26nbsp%3Btoday%20and%20leave%20me%20a%20comment%20below%20with%20what%20use%20cases%20it%20helps%20you%20with.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2728010%22%20slang%3D%22en-US%22%3E%3CP%3ELet's%20take%20a%20look%20at%20how%20the%20GitHub%20Command%20Line%20Tool%20can%20help%20you%20with%20your%20day%20to%20day%20tasks.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22githubcli.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F308488iCD5EEE67C55B5352%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22githubcli.png%22%20alt%3D%22githubcli.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2728010%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESarah%20Lean%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎Sep 07 2021 04:15 AM
Updated by: