GitHub CLI(gh)の入れ方:auth login、clone、Issue/PR 作成
gh を入れて認証し、clone から Issue・PR 作成までターミナルで行う。
Copying PATs from the browser, pasting clone URLs, then switching tabs to file an issue or open a PR adds friction. GitHub CLI (gh) keeps login, clone, issues, and pull requests in the terminal. Install and auth steps follow cli.github.com.
Searchers looking for install GitHub CLI gh auth login(認証) clone create issue PR terminal want a checkable path: install gh, run gh auth login(認証), gh repo clone, then create an issue and a PR from the shell. Verify flags with gh <command> -h on your machine.
gh の用途
Daily issue and PR authors
After commits on a feature branch, run gh pr create without leaving the terminal.
Developers across many org repos
gh repo clone org/repo uses your logged-in identity for private repositories.
Script and CI debugging
Run gh auth status before workflow or release commands to confirm scopes.
GitHub CLI のインストール
- 1
macOS: Homebrew
brew install gh, thengh --version. - 2
Debian / Ubuntu
Add the official apt repository per GitHub docs, then
sudo apt install gh, or use your distro package. Confirm withgh --version. - 3
Windows
winget install GitHub.cliorscoop install gh(verify package names in the store). - 4
Other Linux
Fedora:
sudo dnf install gh. Arch:sudo pacman -S github-cli. Otherwise use GitHub Releases binaries.
gh auth login(認証)
- 1
Start interactive login
Run
gh auth login(認証). Choose GitHub.com (or your Enterprise hostname). - 2
Protocol and credentials
Pick HTTPS or SSH per team policy. HTTPS often uses browser OAuth or a one-time token — follow prompts; never commit tokens.
- 3
Verify
gh auth statusshould show the account and token scopes. Ifgit pushfails, check remote URL and SSH keys. - 4
Multiple accounts (optional)
Use
gh auth switchor host entries documented for your version; seegh auth login(認証) -h.
gh auth login(認証)
gh auth statusgh repo clone でクローン
gh repo clone github/github-cli
cd github-cli
git remote -vWorks for private repos you can read. Plain git clone remains fine once auth is configured.
Issue と PR を作る
| Command | Action | Typical use |
|---|---|---|
gh issue create | New issue | Bug reports, requests |
gh issue list | List issues | Triage |
gh pr create | Open pull request | After pushing a branch |
gh pr status | PR state for current branch | CI feedback |
gh pr checkout 123 | Check out a PR locally | Review |
- 1
Create an issue
In the repo root:
gh issue create --title "Fix login timeout" --body "Steps to reproduce…". Without flags, gh may open an interactive editor. - 2
Push a branch
git checkout -b fix/login, commit,git push -u origin fix/login. - 3
Open a PR
gh pr create --title "Fix login timeout" --body "Closes #42". Usegh pr create --webif your team relies on a PR template in the browser. - 4
Inspect
gh pr view --webopens the PR;gh pr checksshows CI when enabled.
ghtalks to GitHub’s API; it does not replace Git. Usegitfor commits and merges; useghfor hosted objects like issues and pull requests.
- 401 after login
- Try
gh auth refreshor log in again; confirm the correct hostname. - Cannot open a PR
- Check write access or fork workflow; forks may need
--repo owner/upstream. - With lazygit or an IDE
- Use lazygit for staging and commits,
ghfor issues and PRs — see our lazygit guide.
To sync on PR text or a flow diagram, open a browser room from the wbroom homepage — create and join a room.
確認しておきたいこと
gh と git の関係は?
git is version control; gh is GitHub’s official CLI for API and GitHub-specific tasks. Use both.
gh repo clone は必須?
No. After auth, git clone is fine; gh repo clone is a convenient shorthand.
非対話で PR を作れる?
Pass --title, --body, --base, and --head. In scripts, check gh auth status first.
ログアウトは?
gh auth logout. On shared machines, log out before leaving.