How to install GitHub CLI (gh): auth login, clone, and create issues and PRs
Install gh, authenticate, clone a repo, and open issues and pull requests without leaving the terminal.
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.
Who gh is for
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.
Install 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 statusClone with gh 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.
Create issues and pull requests
| 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.
Questions worth checking
How do gh and git relate?
git is version control; gh is GitHub’s official CLI for API and GitHub-specific tasks. Use both.
Must I use gh repo clone?
No. After auth, git clone is fine; gh repo clone is a convenient shorthand.
Non-interactive PR creation?
Pass --title, --body, --base, and --head. In scripts, check gh auth status first.
How do I log out?
gh auth logout. On shared machines, log out before leaving.