Learn the Basics — GitHub’s CLI
GitHub CLI, or
gh, is a free and open source tool that enables you to use GitHub's pull requests, issues, repositories and more directly from your command line.
gh is available via Homebrew by running the command
brew install gh.
You are working in one of your projects, where you will create (a) an issue, (b) a branch and © a pull request to (d) merge changes into your main production branch. We will explore these
gh commands straight from its Manual.
Creating an issue
GitHub Issues helps you to track ideas, feedback, tasks, bugs and plan for your work right where development takes place.
Creating a branch to work on an issue
If you used the
--web flag, you can create a branch to work on an issue directly from the issue page by clicking under Development > Create a branch. Once the branch is created, to start working, you can checkout the branch in your local repository:
This is incredibly useful and convenient because this links any pull request created for that branch, where successfully merging that PR will replace the relationship (from branch to PR) and automatically close the issue.
Creating a pull request to review your work
You finished and committed your work. now you’re ready to create a PR. Pull requests (PR) lets you discuss and review potential changes before (if ‘LGTM’) merging them into production. I would recommend creating your PR interactively. For more information on the available flags, visit CLI Manual: PR Create
Merging your changes to production
Once the changes you’ve made on your head branch are ready to be merged into the main (base) branch, you are ready to push your code to production.
Immediately after this, (a) your issue will be marked as closed, (b) the local and remote development branch will be deleted and your © commit change merged into the main branch. For more information on visit GitHub’s documentation: Collaborating with pull requests.
Originally published: Learn the Basics — GitHub’s CLI