Scott Hanselman

Don't forget about the GitHub Command Line

March 03, 2021 Comment on this post [6] Posted in Open Source
Sponsored By

I spend so much time at the command line using the Windows Terminal. Then I spend a ton of time using git at the command line. But then I ALT+TAB over to GitHub and mess around in the browser.

Why have I been sleeping on the GitHub CLI? - there's a command line interface for GitHub!

I installed with "winget install GitHub.cli" but you can get it from if you like.

Then you run gh auth login once:

gh auth login
? What account do you want to log into?
? What is your preferred protocol for Git operations? HTTPS
? Authenticate Git with your GitHub credentials? Yes
? How would you like to authenticate GitHub CLI? Login with a web browser

Now you've got a new command "gh" to play with!

I went over to one of my local git clones for the Hanselminutes Podcast website and I can now list the open Pull Requests from the command line!

Open PRs on GitHub

Here's the real time saver that Dan Wahlin reminded me about: gh repo create!

> git init
Initialized empty Git repository in D:/github/ghcliblogpost/.git/
> gh repo create
? Repository name ghcliblogpost
? Repository description This is a test for my GH CLI Blog post
? Visibility Public
? This will add an "origin" git remote to your local repository. Continue? Yes
✓ Created repository shanselman/ghcliblogpost on GitHub
✓ Added remote

Fantastic! You can even gh issue create!

gh issue create

Creating issue in shanselman/hanselminutes-core

? Title This is a test issue
? Body <Received>
? What's next? Submit

Checking out a Pull Request is a great time saver as well. Go check out and see how it can help you today!

Sponsor: Protect your apps from reverse engineering and tampering with PreEmptive, the makers of Dotfuscator. Dotfuscator has been in-the-box with Microsoft Visual Studio since 2003. Visit for a professional-grade trial.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
March 08, 2021 21:08
I don't understand the affinity for CLIs. Unless you're some sort of admin that needs advanced capabilities on a regular basis or a number of machines, what's wrong with a simple UI? As just a regular developer, I don't have time to memorize or lookup all that syntax.
March 09, 2021 13:51
I'd settle for Git working from the command line in a repeatable fashion. Migrating SVN repo to Git, eventually get commands figured out and complete a test migration to AzDevOps. Now I want to do it again as another test to tweak things, use the same commands and git says "mwhahahahaha - no!" despite running the same commands that previously worked, checkout my stackoverflow post for the full horror show, if interested.
March 09, 2021 16:08
It’s the best blog for a beginner. I did not see so good work in my life. Thanks a lot for sharing such an amazing blog
March 09, 2021 17:12
The problem is that this set of commands are not standardized, like those for git, but it's different for each git-hosting platform - GitHub, GitLab, Azure DevOps etc..
It would be great to have a single command to create a pull request, as an example..

As a developer, you might work today with a project on GitHub, after one year on another that is using Azure DevOps etc.
March 09, 2021 20:36
@Jeff The great thing about a CLI is you can put the commands in a script and reuse them. I've saved entire days (weeks?) of my life by re-using keystrokes that way. Mouse movements and clicks are much difficult to reuse. 😉 I assume Scott's reasoning is similar.

@Peter I have no notes online (a chronic backlog item), but I believe this page was helpful a few years ago:
March 11, 2021 18:00
What is your powerline theme?

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.