- Open project in Github
- List all issues
- Create new issue
- List all PRs
- Check PR status
- Merge PR into main
- Switch between branches
Github CLI installed?
Check by running gh version
1. Open project in Github
Open the github homepage of the current project in the browser.
gh browse
Github CLI's response:
Opening github.com/repo/my-repo in your browser.
2. List all issues
Return all outstanding issues in the repository.
gh issue list
Github CLI's response:
Showing 3 of 3 open issues in repo/my-repo
#178 bug when downloading pdf about 3 minutes ago
#166 refactor stripe api call about 2 days ago
#126 depreciate pacakge 20 days ago
3. Create new issue
Did you find a new bug?
Add something as a to-do for later on Github Issues. The CLI will prompt you a few questions.
gh issue create
Github CLI's response:
Creating issue in repo/my-repo
? Title bug when downloading pdf
? Body <Received>
? What's next? Submit
https://github.com/repo/my-repo/issues/178
4. List all PRs
Retrieve an overview of all PR in the repository.
gh pr list
Github CLI's response:
Showing 3 of 3 open pull request in repo/my-repo
#170 feat/stripe-checkout
#142 feat/vitally-api
#139 bug/profile-responsiveness
5. Check PR status
To find out if the PR passed the automated testing suite.
gh pr status
Github CLI's response:
Relevant pull requests in repo/my-repo
Current branch
#177 new-feature [new-feature]
✓ Checks passing
6. Merge PR into main
A useful shortcut to easily delete a branch from both Github and your local enviroment.
2 options:
- From the local main branch
Merge a PR into the main branch by specifying the PR number.
gh pr merge 177
- From the PR branch
No need to specific the PR number.
gh pr merge
Github CLI's response:
? What merge method would you like to use? Create a merge commit
? Delete the branch locally and on GitHub? Yes
? What's next? Submit
✓ Merged pull request #177 (new-feature)
✓ Deleted branch new-feature
7. Switch between branches
This CLI command is based upon a popular extension.
Install the extension
gh extension install mislav/gh-branch
Run the extension.
gh branch
Move across branches with up and down arrow. Hit enter to select the branch.
Github CLI's response:
feat/stripe-checkout 6 weeks ago
feat/postmark-integration 2 weeks ago
> new-feature 25 hours ago
bug/profile-responsiveness 2 hours ago
4/4
Top comments (2)
I don't know why, I always prefer using the CLI for everything except merging PRs - I always use the GUI for that. Maybe pressing the button makes it feel more official somehow... one last chance to check things over.
This command reference sheet is very helpful, thanks!
That green merging button has a long legacy. It is definitely linked to making big changes work (or fail when something was missed 👀).
When a CI testing suite is set-up it gives more confidence to merge by cli. It's one my favorite timesavers as it automatically deletes the branch on github and local. A few second here and there, over again.