Gh: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 48: Line 48:
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
gh auth setup-git --hostname github.mycompany.com
gh auth setup-git --hostname github.mycompany.com
 
gh auth login --hostname github.mycompany.com status --with-token < mytoken.txt
gh repo clone <org>/<repo-name>
gh repo clone <org>/<repo-name>
</syntaxhighlight>
</syntaxhighlight>

Revision as of 21:13, 2 May 2022

External

Internal

Overview

GitHub-specific CLI. Can be used to authenticate, clone repositories, etc.

Installation

Mac

brew install gh

Linux

sudo dnf install -y 'dnf-command(config-manager)'
sudo dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
sudo dnf install -y gh

Authentication

Configure Git to Use gh as Credential Helper

gh repository cloning commands, and probably others, will continue to challenge for username and password, unless git is configured to use gh as credential helper:

gh auth setup-git [--hostname enterprise.internal]

Authentication Status

gh auth status --hostname enterprise.internal --show-token

Authenticate with a Personal Access Token

gh auth login --hostname enterprise.internal --with-token < mytoken.txt
gh auth login --hostname github.mycompany.com status --with-token < mytoken.txt

Logout

gh auth --hostname github.mycompany.com logout

Clone Repository

gh repo clone <org>/<repo-name>

Full Sequence of Operations for Cloning, Including Authentication

gh auth setup-git --hostname github.mycompany.com
gh auth login --hostname github.mycompany.com status --with-token < mytoken.txt
gh repo clone <org>/<repo-name>