Git & GitHub Cheat Sheet
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. |
A single-page, colour-coded summary of the Git and GitHub essentials — installing and configuring Git, creating
or cloning a repository, the three areas (working tree, staging area, repository) and the file lifecycle, staging
and committing, inspecting history, undoing changes, branch commands, the checkout/switch/restore split,
stashing, tags and GitHub releases, remotes (fetch/pull/push, -u, --force-with-lease), merging and
rebasing with conflict resolution, GitHub flow in six steps, and pull requests with the GitHub CLI and the three
merge methods, and a Move a repository block — plus a strip of IntelliJ IDEA and VS Code shortcuts and
commands. It reflects Git 2.55.x, GitHub CLI 2.101.x, IntelliJ IDEA 2026.2 and current stable VS Code with the
GitHub Pull Requests and Issues extension.
For the full explanation, every option, and additional examples, see the dedicated pages:
Foundations — Getting Started with Git and GitHub and Repositories and Cloning.
Everyday work — Commits, Branches, Checkout, Switch and Restore, and Tags and Releases.
Collaborating — Fetch, Pull and Push, Merging, Rebasing and Conflicts, and Pull Requests.
Moving repositories — Migrating Repositories Between Providers and Transferring Repositories Between GitHub Accounts.
The sheet’s Move a repository block summarizes both pages with placeholders: copy a repository to another host
with every ref and its Git LFS objects (the target must be an empty repository, because --mirror deletes target
refs the copy does not have), or hand a GitHub repository to another owner with a transfer:
git clone --mirror <source-url> # bare copy of every ref; then cd <repo>.git
git lfs fetch --all # only if the repository uses Git LFS
git push --mirror <empty-target-url>
git lfs push --all <empty-target-url>
gh api --method POST repos/<owner>/<repo>/transfer -f new_owner=<new-owner> # GitHub-to-GitHub ownership transfer