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. Run once per project.
Explain the three Git states: working directory, staging area, repository.
Working directory = your files on disk. Staging area (index) = changes marked for commit via `git add`. Repository = committed history in .git folder.
What's the difference between `git add .` and `git add <file>`?
`git add .` stages all modified/new files in the current directory and subdirectories. `git add <file>` stages only the specified file. Both ignore deleted files unless you use `git add -A`.
What does `git commit -m "message"` do?
Creates a snapshot of staged changes with the given message. The commit is permanent in local repo history. `-m` flag allows inline message; omitting it opens an editor.
How do you undo staged changes without losing them?
Use `git reset HEAD <file>` (or `git restore --staged <file>` in Git 2.23+). Removes file from staging area but keeps changes in working directory.
What's the gotcha with `git checkout` vs. `git switch` for branches?
`git checkout <branch>` switches branches but also checks out files, risking accidental overwrites. `git switch <branch>` (Git 2.23+) is safer and clearer. `git checkout` is overloaded for both branches and file recovery.
Explain `git merge` and when merge conflicts occur.
Merges another branch into current branch. Conflicts occur when both branches modify the same lines differently. Git marks conflicts with `<<<<<<<`, `=======`, `>>>>>>>` markers; you must manually resolve and re-commit.
What's the difference between `git merge` and `git rebase`?
`git merge` creates a merge commit, preserving both branch histories. `git rebase` replays commits on top of another branch, creating a linear history. Rebase rewrites history (avoid on public branches); merge is safer for shared code.
What does `git push origin <branch>` do, and what's a common gotcha?
Uploads local commits to remote branch. Gotcha: if remote has newer commits, push fails. Use `git pull` first to sync, or `git push -f` to force (destructive—avoid on shared branches).
Explain detached HEAD state and how to recover from it.
Occurs when checking out a commit hash instead of a branch; you're not on any branch. Changes here are orphaned if you switch away. Recover by `git switch -c <new-branch>` to save work, or `git reset --hard <safe-commit>` to discard.
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 →