Programming flashcards

Git Commands Cheat Sheet

50 Git command flashcards for commits, branches, diffs, recovery, rebasing, worktrees, and debugging history.

50 cards By @mazo
#git#commands#version-control#workflow#recovery
Study this deck free Browse Programming

About this deck

This 50-card Git command deck covers the normal edit-stage-commit workflow, branch collaboration, patch inspection, and recovery tools such as restore, revert, reflog, and abort commands.

The notes call out history-rewriting and destructive boundaries so commands are learned with their consequences, not as a blind list.

50cards
Git beginner to intermediatelevel
developers learning Git, team contributors, and command-line workflow reviewaudience

What you will learn

How to study this deck

Recommended study setup

Scope

This deck teaches common command intent, not every option or a replacement for checking repository policy before rewriting shared history.

Review notes

Command intent and recovery guidance checked against current Git documentation on 2026-07-10.

All 50 cards in this deck

FrontBackStudy note
git initCreate a new Git repository in the current folder.Safety cue: inspect git status and the relevant diff before running a command that changes history or the working tree.
git clone <url>Copy a remote repository to your machine.Safety cue: inspect git status and the relevant diff before running a command that changes history or the working tree.
git statusShow changed files and branch state.Safety cue: inspect git status and the relevant diff before running a command that changes history or the working tree.
git add <file>Stage a file for the next commit.Safety cue: inspect git status and the relevant diff before running a command that changes history or the working tree.
git commit -m "message"Create a commit with staged changes.Safety cue: inspect git status and the relevant diff before running a command that changes history or the working tree.
git log --onelineShow compact commit history.Safety cue: inspect git status and the relevant diff before running a command that changes history or the working tree.
git diffShow unstaged changes.Safety cue: inspect git status and the relevant diff before running a command that changes history or the working tree.
git diff --stagedShow staged changes.Safety cue: inspect git status and the relevant diff before running a command that changes history or the working tree.
git switch -c <branch>Create and switch to a new branch.Safety cue: inspect git status and the relevant diff before running a command that changes history or the working tree.
git merge <branch>Combine another branch into the current one.Safety cue: inspect git status and the relevant diff before running a command that changes history or the working tree.
git rebase <branch>Reapply commits on top of another branch.Safety cue: inspect git status and the relevant diff before running a command that changes history or the working tree.
git fetchDownload remote changes without merging them.Safety cue: inspect git status and the relevant diff before running a command that changes history or the working tree.
git pullFetch and integrate changes from the remote branch.Safety cue: inspect git status and the relevant diff before running a command that changes history or the working tree.
git pushUpload local commits to the remote branch.Safety cue: inspect git status and the relevant diff before running a command that changes history or the working tree.
git restore <file>Discard unstaged changes in a file.Safety cue: inspect git status and the relevant diff before running a command that changes history or the working tree.
git reset <commit>Move the branch pointer, optionally unstaging changes.Safety cue: inspect git status and the relevant diff before running a command that changes history or the working tree.
git stashTemporarily save uncommitted changes.Safety cue: inspect git status and the relevant diff before running a command that changes history or the working tree.
git cherry-pick <commit>Apply a specific commit onto the current branch.Safety cue: inspect git status and the relevant diff before running a command that changes history or the working tree.
git blame <file>Show which commit last changed each line.Safety cue: inspect git status and the relevant diff before running a command that changes history or the working tree.
git remote -vList configured remote repositories and URLs.Safety cue: inspect git status and the relevant diff before running a command that changes history or the working tree.
git branchList local branches.Add --all to include remote-tracking branches.
git switch <branch>Switch to an existing branch.Prefer switch for branch navigation; checkout also has unrelated file-restoration behavior.
git branch -d <branch>Delete a fully merged local branch.Use lowercase -d first; uppercase -D forces deletion.
git log --graph --oneline --allShow a compact graph of all branch histories.Useful for understanding merges and branch divergence.
git show <commit>Show a commit and its patch.Pass a path after -- to limit the display to one file.
git diff main...featureShow changes introduced on feature since its merge base with main.Three dots are useful for reviewing a branch as a pull request.
git add -pInteractively stage selected hunks.Helps split unrelated edits into focused commits.
git commit --amendReplace the latest commit with the staged changes and/or a new message.Avoid amending a shared commit unless you intend to rewrite remote history.
git revert <commit>Create a new commit that reverses an earlier commit.Usually safer than reset for history already shared with others.
git reset --soft <commit>Move HEAD while keeping changes staged.Useful for rebuilding recent local commits without discarding file changes.
git restore --staged <file>Unstage a file while keeping its working-tree changes.Check git diff afterward to confirm the edit remains.
git stash listList saved stashes.Each entry has a reference such as stash@{0}.
git stash push -m "message"Stash tracked changes with a descriptive label.Use -u when untracked files also need to be included.
git stash popApply the newest stash and remove it if successful.Use git stash apply when you want to keep the stash entry.
git reflogShow recent local movements of HEAD and branch references.Often the best recovery trail after an accidental reset or rebase.
git bisect startBegin a binary search for the commit that introduced a problem.Mark known endpoints with git bisect bad and git bisect good.
git tag -a <tag> -m "message"Create an annotated tag.Annotated tags store a tagger, date, and message and suit releases.
git push -u origin <branch>Push a branch and set its upstream.Later git push and git pull can use the configured upstream.
git remote add origin <url>Add a named remote repository.Origin is conventional, not mandatory.
git fetch --pruneFetch updates and remove stale remote-tracking references.It does not delete local branches.
git clean -nPreview untracked files that git clean would remove.Use the dry run before any destructive clean command.
.gitignoreLists untracked path patterns Git should ignore.It does not stop tracking files that are already committed.
git cherry-pick --no-commit <commit>Apply a commit’s changes without creating the commit yet.Useful when combining or editing selected patches.
git rebase -i <base>Interactively reorder, squash, edit, or drop local commits.Rewrites commit IDs; coordinate before changing shared history.
git merge --abortReturn to the state before a conflicted merge began.Available when a merge is in progress and cannot be completed cleanly.
git rebase --abortReturn to the state before the current rebase began.Use when resolving the rebase is not the right path.
git worktree add <path> <branch>Check out another branch in a linked working directory.Useful for parallel tasks without repeatedly switching one worktree.
git config --global user.nameRead or set the default author name for commits.Use --local instead when one repository needs different identity settings.
git log -S"text"Find commits where the number of occurrences of text changed.Useful for locating when code or configuration was introduced or removed.
git shortlog -snSummarize commit counts by author.Add --all to include all refs, not just the current history.

Frequently asked questions

Does this Git deck include recovery commands?

Yes. It covers restore, revert, reflog, stash, merge/rebase abort, and safe inspection before cleanup.

Does it explain dangerous Git commands?

Notes mark commands that rewrite history or can discard work and favor preview or reversible workflows.

Can I learn Git only with flashcards?

Use the deck for recall, then practice each workflow in a disposable repository.

Is the Git Commands Cheat Sheet flashcard deck free?

Yes. You can study it free in your browser on MazoCards. Create a free account to save progress, track streaks, and sync across devices.

JavaScript Array Methods

50 JavaScript array method flashcards covering transformation, search, mutation, copying methods, iteration, and common pitfalls.

50 cards
Open

React Hooks Essentials

40 React 19.2 hook flashcards covering state, effects, refs, transitions, actions, external stores, common pitfalls, and when not to use a hook.

40 cards
Open

SQL Basics: Queries & Joins

50 SQL flashcards covering queries, filtering, joins, aggregation, subqueries, CTEs, windows, transactions, constraints, and query plans.

50 cards
Open

CSS Flexbox and Grid

CSS layout flashcards covering Flexbox, Grid, alignment, tracks, gaps, and responsive patterns.

41 cards
Open

Start studying Git Commands Cheat Sheet

Study these 50 cards free, then create an account to save your progress and build a streak.