GitHub CLI (gh)
Hva er GitHub CLI?
Section titled “Hva er GitHub CLI?”GitHub CLI (også bare kalt gh
) er GitHubs kommandolinje-verktøy som lar deg jobbe med GitHub repositories, issues, pull requests og fra den vakre terminalen din.
Installering
Section titled “Installering”brew install gh
Les installasjonsinstruksjonene for andre operativsystemer.
Autentisering
Section titled “Autentisering”F�r du kan bruke GitHub CLI må du autentisere deg:
gh auth login
Følg instruksjonene for å logge inn via nettleser eller personal access token.
Tips og triks
Section titled “Tips og triks”Pull Requests
Section titled “Pull Requests”Opprette pull request
Section titled “Opprette pull request”# Opprett PR fra current branchgh pr create
# Opprett draft PRgh pr create --draft
Jobbe med eksisterende PRs
Section titled “Jobbe med eksisterende PRs”# List alle PRsgh pr list
# Se detaljer om en PRgh pr view 123
# Sjekk ut en PR lokaltgh pr checkout 123
# Lukk en PRgh pr close 123
PR reviews
Section titled “PR reviews”# Be om reviewgh pr edit 123 --add-reviewer @username
# Godkjenn en PRgh pr review 123 --approve
# Request changesgh pr review 123 --request-changes --body "Trenger endringer her"
# Kommenter på PRgh pr comment 123 --body "God jobb!"
Issues
Section titled “Issues”Opprette og administrere issues
Section titled “Opprette og administrere issues”# Opprett nytt issuegh issue create --title "Bug rapport" --body "Beskrivelse av bug"
# List issuesgh issue list
# Se issue detaljergh issue view 456
# Lukk issuegh issue close 456
# Reopen issuegh issue reopen 456
# Assign issue til deg selvgh issue edit 456 --add-assignee @me
Issue templates
Section titled “Issue templates”# Opprett issue med templategh issue create --template bug_report.md
Repository operasjoner
Section titled “Repository operasjoner”Klone repositories
Section titled “Klone repositories”# Klon med gh (setter opp riktige remotes)gh repo clone owner/repo
# Klon din egen forkgh repo clone repo --fork
Repository info
Section titled “Repository info”# Se repository infogh repo view
# Se repository info i nettleseren dingh repo view --web
# Se repository info for annet repogh repo view owner/repo
# List repositoriesgh repo list owner
# Opprett nytt repositorygh repo create my-new-repo --public
Workflow og Actions
Section titled “Workflow og Actions”Se workflow status
Section titled “Se workflow status”# List workflow runsgh run list
# Se detaljer om en workflow rungh run view 789
# Se logs fra workflowgh run view 789 --log
Trigger workflows
Section titled “Trigger workflows”# Trigger workflow manueltgh workflow run "CI" --ref main
Webhooks og notifications
Section titled “Webhooks og notifications”# Se notifikasjonergh api notifications
Vanlige workflows
Section titled “Vanlige workflows”Feature branch workflow
Section titled “Feature branch workflow”# Opprett og bytt til ny branchgit checkout -b feature/ny-feature
# Gjør endringer og commitgit add . && git commit -m "Legg til ny feature"
# Push og opprett PRgh pr create --title "Ny feature" --body "Beskrivelse"
Review workflow
Section titled “Review workflow”# Se PRs som venter på reviewgh pr list --search "review-requested:@me"
# Sjekk ut PR for lokal testinggh pr checkout 123
# Review PRgh pr review 123 --approve --body "LGTM!"
Troubleshooting
Section titled “Troubleshooting”Vanlige problemer
Section titled “Vanlige problemer”Authentication issues
Section titled “Authentication issues”# Sjekk auth statusgh auth status
Permission issues
Section titled “Permission issues”# Sjekk hvilke scopes du hargh auth status
# Login med flere scopesgh auth login --scopes repo,admin:repo_hook