Github CLI is a console tool for working on interactions with Github from terminal. This tool allow to add new extension by developing them and adding to the main gh
prompt as sub-commands from your command line. Read More about how to implement custom Github CLI extensions.
For this example we use a private extension not available for public purposes but you can explore some others existing Github CLI extensions. See the list of available extensions at https://github.com/topics/gh-extension.
In order to follow the next steps just change [RESOURCE]
by your marked extension.
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
sudo apt update \
&& sudo apt install gh -y
USAGE: $ gh <command> <subcommand> [flags]
CORE COMMANDS
auth: Authenticate gh and git with GitHub
browse: Open the repository in the browser
codespace: Connect to and manage codespaces
gist: Manage gists
issue: Manage issues
pr: Manage pull requests
release: Manage releases
repo: Manage repositories
Get more info about gh tool: $ gh -h
$ gh auth login
# Select: GitHub.com > HTTPS > y > Login from a web browser
gh extension install provider/gh-[RESOURCE]
$ gh repo clone cli/cli
Cloning into 'cli'...
$ cd cli
~/workspace/cli$
$ gh issue create
Type: "<YOUR_NAME>_contribution" as the issue title > Enter > Enter
Copy the number located at the end of former URL. This number corresponds to the issue ID.
Now you can create a new working branch:
$ gh [RESOURCE] create-branch --issue <ISSUE_ID>
Note: Replace <ISSUE_ID> with the ID you copied from the URL. When prompted, select documentation as branch type and press Enter. Enter a description (for example: "Test contribution") and press Enter. Type Y to confirm the branch creation and press Enter. You receive a confirmation message that the branch has been created.
Now edit a single file and add some basic changes:
$ git add test-contributions/test-contributions.md
and create a new commit:
$ git commit -m "This is your contribution message"
Finally: add a new Pull Request
$ gh [RESOURCE] create-pr
# Select: Y > Y
This returns the URL of your pull request. Open the pull request URL from your web browser.