Quiz: What do you use every day, that is essential to your development workflow, and has a vast and complex UI and API?
Answer: GitHub, of course!
You likely interact with the
git commands in terminal for some operations and then go to the https://github.com web site when you need to perform other operations. This back and forth between terminal and the browser to perform git operations could be more efficient if you could stay in one zone: CLI or the browser: Well, the GitHub team has felt this too.
They have released a new CLI called
gh, in beta.
If you are in a hurry, here are all of the links you'll need, in one place:
You can check your version at anytime with the following command.
You're working on your code and you run into a bug. But you are busy working on another challenge and don;t want to get distracted. Now you can run a quick command to create an issue without leaving your terminal!
This is awesome! Now you can stay focused on your current work and get back to this later.
gh issue create -t "Save invokes a 500 error" -b "steps to reproduce: fill out the form, then press save."
Want to see what issues are open?
gh issue status
This produce the following output format:
Relevant issues in johnpapa/hello-worlds Issues assigned to you There are no issues assigned to you Issues mentioning you There are no issues mentioning you Issues opened by you #1 Save invokes a 500 error about 1 minute ago
You know how sometimes you want to create a repo locally and in GitHub from your computer? Use the following command and you can create a repo named
hello-world, add a description, and make the repo public!
gh repo create hello-world -d "A react app for the web" --public
You're working on your code locally and you want to go visit the repo in the browser. Now you have to go type in that URL in the address bar. Nope! Run the following command from your code's local folder and the browser opens right to your repo!
gh repo view # this will open your repo, such as https://github.com/johnpapa/hello-world
You can run some common commands like cloning a repo too.
gh repo clone firstname.lastname@example.org:johnpapa/hello-world.git
Want to fork a repo? How about fork it and clone it locally to your computer? Try this command.
gh repo johnpapa/hello-worlds fork --clone
You've made your changes to your branch and now it is time to create a Pull Request (PR). You could go to the browser, browse to your repo, and start clicking around to create the PR. Or you could use the following command to create a PR!
--fill flag indicates that you won't be prompted for title/body. Instead it will just use the commit info for those.
gh pr create --fill
A great place to start is with the
--help flag. You can show the options available for any command by appending the
get help on commands
gh issue --help gh pr --help gh repo --help
gh pr checkout --help gh pr create --help gh pr list --help gh pr status --help gh pr view --help
gh repo clone --help gh repo create --help gh repo fork --help gh repo view --help
gh issue create --help gh issue list --help gh issue status --help gh issue view --help
There is a lot more that you can do, so go ahead and read the
No worries, you can mix and match using the
git commands and the
gh a try! GitHub is accepting feedback now during their beta through this short survey.