Skip to content

Instantly share code, notes, and snippets.

@psiborg
Created July 14, 2026 13:39
Show Gist options
  • Select an option

  • Save psiborg/caf6fd45b68ae1f93fdcf81252add4a6 to your computer and use it in GitHub Desktop.

Select an option

Save psiborg/caf6fd45b68ae1f93fdcf81252add4a6 to your computer and use it in GitHub Desktop.
Reference for git and gh

Reference for git and gh

The core distinction: git is the version-control engine that talks to any remote, while gh wraps GitHub-specific operations (PRs, issues, releases, Actions) and some convenience clones on top of git. A below means there's no meaningful equivalent for that tool.

Setup

Task git gh
Authenticate Configure SSH keys or a credential helper (git config credential.helper) gh auth login
Check auth status gh auth status
Set a config value git config --global user.name "Name" gh config set editor vim
Clone a repo git clone <url> gh repo clone owner/repo
Create a new repo git init (local only) gh repo create
Add a remote git remote add origin <url> — (set automatically on clone/create)

Common

Task git gh
Check working-tree status git status
Stage changes git add <file>
Commit git commit -m "msg"
Push / pull git push / git pull
Create a branch git switch -c <branch>
Fork a repo gh repo fork
Open a pull request gh pr create
List pull requests gh pr list
Check out a PR locally git fetch origin pull/<n>/head + branch gh pr checkout <number>
View a PR gh pr view <number>
Open repo in browser gh browse / gh repo view --web

Advanced

Task git gh
Review / approve a PR gh pr review
Merge a PR git merge (local branches) gh pr merge <number>
Manage issues gh issue create / gh issue list
Create a release git tag <tag> + git push --tags gh release create <tag>
Manage gists gh gist create <file>
Run / view Actions gh workflow run / gh run list
Call the GitHub API gh api <endpoint>
Define aliases git config alias.co checkout gh alias set co pr checkout
Cherry-pick git cherry-pick <sha>
Rebase (incl. interactive) git rebase [-i] <ref>

A useful mental model: anything about history and local state stays in git; anything that touches GitHub-the-service is where gh earns its place. The two overlap only on a handful of convenience wrappers (clone, merge, browse).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment