Flashcards · Git · Free
Git flashcards, generated for you.
Example Git study cards to learn from right now — then generate a full set from your own notes (plus a practice quiz) and export to Quizlet or Anki. Free, no account needed.
Example Git flashcards
What does `git init` do?
Creates a new `.git` directory in the current folder, initializing a local Git repository and enabling version control for that project.
Explain the difference between `git add` and `git commit`.
`git add` stages changes to the index (staging area); `git commit` records staged changes to the repository history with a message. You must add before commit.
What is the staging area (index) and why does it matter?
An intermediate layer between your working directory and repository. It lets you selectively stage specific changes before committing, enabling atomic, logical commits instead of committing everything at once.
What does `git checkout <branch>` do, and what's the modern alternative?
`git checkout` switches to a branch. Modern alternative is `git switch <branch>` (Git 2.23+), which is clearer. Checkout also reverts files, causing confusion—use `git restore <file>` for that instead.
Explain `git merge` vs. `git rebase` in one sentence each.
`git merge` creates a merge commit combining two branches, preserving history. `git rebase` replays commits from one branch onto another, creating a linear history (rewrites commits).
What is a detached HEAD state, and how do you get into it?
A state where HEAD points directly to a commit instead of a branch. Caused by checking out a specific commit, tag, or remote branch. Risk: commits made here may become orphaned if you switch branches without creating a new branch first.
What does `git fetch` do, and how is it different from `git pull`?
`git fetch` downloads objects and refs from a remote without modifying your working directory. `git pull` = `git fetch` + `git merge` (or `git rebase`), automatically integrating remote changes into your current branch.
Why is `git push -f` (force push) dangerous, and when is it justified?
Force push rewrites remote history, potentially losing others' commits and causing conflicts for collaborators. Justified only on personal branches or with team agreement (e.g., cleaning up local-only feature branches before deletion).
What does `git reflog` show, and how can it rescue lost commits?
`git reflog` logs all reference updates (commits, resets, checkouts) even if not reachable from any branch. Use it to find the SHA of a lost commit after an accidental reset, then `git checkout <sha>` or branch from it.
Explain the gotcha: why does `git status` show modified files after `git add`?
If you modify a file *after* staging it, both the staged and unstaged versions exist. `git status` shows the unstaged changes. Run `git add` again to stage the latest version, or `git diff --staged` to see what's actually committed.
Make your own Git study set
Flashcards for related topics
Studying Git to build with AI? MindloomHQ turns it into real skills — structured courses, agent projects, and certificates.
Explore MindloomHQ →