Git | Arbeiten mit der GitHub Kommandozeile

Installation

Laden Sie das Tool von dieser Seite und installieren Sie es. Das Tool besteht aus einer Datei: gh

Stellen Sich sicher, dass sich der Installationsordner in ihrem PATH Variable befindet.

Danach einfach das Tool mal aufrufen

Authentifizierung

Anmelden

gh auth login --hostname github.com

Default Protokoll einstellen

 gh config set -h github.com git_protocol ssh

Credentials aktualisieren

gh auth status

Aktualisieren der Credentials:

gh auth refresh

Konfiguration

Editor setzen

gh config set editor editorName

Repositories

Erstellen

gh repo create <user>/<reponame>
gh repo create <user>/<reponame> --private --enable-issues=false

Clonen

gh repo clone <user>/<reponame>

Fork

gh repo clone <user>/<reponame>
gh repo clone <user>/<reponame> --clone=true --remote=true

Löschen

gh alias set delete 'api -X DELETE repos/$1'
gh auth refresh -h github.com -s delete_repo
# usage (WARNING: no confirmation!)
gh delete user/myrepo

Informationen

Liste der Repositorynamen

gh repo list --limit 1000 --json name --jq '.[].name'

List der Repository-URLs

gh repo list microsoft --json url --jq '.[].url'

Liste filtern (in PowerShell)

gh repo list microsoft --limit 3000 --json url --jq '.[].url'  |
Select-String PowerBI -NoEmphasis                              |



Suchen nach Repositorynamen

gh repo list --limit 1000 --json name --jq '.[].name | match(".*Angular.*") | .string'

Issues

gh issue list

Alle “issues” mit dem Status “all”

gh issue list --state "all"
gh issue list -s "all"
gh issue list --assignee "n8ebel"
gh issue list -a "n8ebel"

Check Issue Status

gh issue status
gh issue list --state "closed"
gh issue list -s "closed"
gh issue list --label "bug"gh issue list -l "bug"
gh issue list
gh issue list -l "enhancement"

Issues anzeigen

gh issue view "15"
gh issue list -a "n8bel" -l "bug"

Issues erstellen

gh issue create -t "Sample Issue Title" -b "Sample issue description"
gh issue create --web

Hilfreiche CLI Aliases

gh issue list --label "bug"
alias listbugs='gh issue list --label "bug"'
alias listmybugs='gh issue list -a "<username>" -l "bug"'

Pull Requests verwalten

List Pull Requests

gh pr list
gh pr list --state "all"
gh pr list  -s     "all"
gh pr list --assignee "n8ebel"
gh pr list  -a        "n8ebel"

Check Pull Request Status

gh pr list --state "closed"
gh pr list -s "closed"
gh pr list --label "bug"
gh pr list -l "bug"
gh pr list
gh pr list -l "enhancement"

Pull Request anzeigen

gh pr view "14"
gh pr list -a "n8bel" -l "bug"

Pull Request erstellen

gh pr create
gh pr create -t "Sample Issue Title" -b "Sample issue description"
gh pr create --web

Praktische Beispiele

Alle Repositories clonen, deren Namen einem bestimmte Suchmuster entspricht

gh repo list microsoft --limit 3000 --json url --jq '.[].url' |
Select-String PowerBI -NoEmphasis |

Repisitories