gh is a new CLI that enables you to work seamlessly with GitHub on the command line.
As of the date of writing this post, the tool is still in its early stages of development.
brew install github/gh/gh
gh, you can create, view, and checkout pull-requests. You can also create and view issues. Let's view its options:
$ gh pr create --help Create a pull request Usage: gh pr create [flags] Flags: -B, --base string The branch into which you want your code merged -b, --body string Supply a body. Will prompt for one otherwise. -d, --draft Mark pull request as a draft -t, --title string Supply a title. Will prompt for one otherwise. -w, --web Open the web browser to create a pull request Global Flags: --help Show help for command -R, --repo OWNER/REPO Select another repository using the OWNER/REPO format
Now let's create a simple PR:
$ gh pr create --base master Creating pull request for test_branch into master in MarounMaroun/git_examples
We'll now be prompted to enter the PR title:
$ gh pr create --base master Creating pull request for test_branch into master in MarounMaroun/git_examples ? Title My first PR from CLI!
Continuing with the prompt, we'll be asked to enter the PR's description, and finally a validation window:
? Submit? [Use arrows to move, type to filter] > Yes Edit Cancel
After hitting "Yes", the PR will be created for us:
Feel free to explore the command:
gh --help gh pr --help gh pr create --help gh issue view --help # and so on...