Skip to content

Try “polymorphism”, “TCP handshake” or “git rebase”.

    Computer Basics / Git

    Quick Reference

    Glossary and cheat sheet for Git — the page to reread before an interview.

    Extra: Reference7 min read

    Glossary#

    TermPlain meaningChapter
    version control / Gittracking every version of files / the dominant tool1
    distributedevery clone has the full history1
    GitHub / GitLabhosting + collaboration services for Git1
    repository / .gita tracked project / where Git keeps its history2
    working directorythe files you see and edit2
    staging area / indexthe changes that will go into the next commit2
    commita saved snapshot with message, author, time, parent2, 3
    untrackeda file Git isn't tracking yet2
    hash / SHA-1content fingerprint / the 40-hex-character hash Git uses3
    blob / tree / commit objectfile contents / directory listing / snapshot record3
    parentthe previous commit a commit points to3
    brancha movable pointer to a commit4
    HEAD / detached HEAD"you are here" / pointing at a commit, not a branch4
    merge / fast-forward / three-way mergecombine branches / just move the pointer / combine via merge base5
    merge base / merge commitlast shared commit / a commit with two parents5
    merge conflict / conflict markerssame lines changed differently / <<<<<<< ======= >>>>>>>5
    rebase / interactive rebase / squashreplay commits elsewhere / edit a series of commits / combine commits6
    remote / originanother copy of the repo / its default name7
    clone / fetch / pull / pushcopy / download / download + integrate / upload7
    remote-tracking branch (origin/main)your record of the remote's branch7
    force push / --force-with-leaseoverwrite remote history / only if nobody else pushed7
    pull request / code reviewproposed merge with discussion / teammates checking it8
    branch protectionrules forcing changes through reviewed PRs8
    trunk-based / GitFlow / feature flagshort branches to main / long-lived develop+release / runtime on/off switch8
    restore / amend / reset / revertdiscard edits / redo last commit / move branch back / add an undoing commit9
    stashpark uncommitted changes9
    refloglog of every place HEAD has been9
    .gitignore / Git LFSfiles never to track / storage for big files10
    secret scanningtools that catch keys before/after commit10
    diff / blame / cherry-pick / tagcompare / who changed each line / copy one commit / name a release11
    bisectbinary search through history for the breaking commit11

    Cheat Sheet#

    Daily

    Output
      git status · git add -p · git commit -m "Imperative summary" · git log --oneline --graph
      git switch main && git pull --rebase · git switch -c feature/x · git push -u origin feature/x

    Combine

    Output
      git merge other          conflicts → edit, remove markers → git add → git commit     (git merge --abort)
      git rebase main          own unshared commits only                                   (git rebase --abort)

    Undo — choose by situation

    Output
      uncommitted edits           git restore file            (lost forever)
      unstage                     git restore --staged file
      last commit, not pushed     git commit --amend
      local commits               git reset --soft|--mixed|--hard HEAD~N
      pushed commit               git revert <hash>           ← the safe one for shared branches
      switch tasks                git stash / git stash pop
      "I lost it"                 git reflog → git reset --hard <hash>

    Never

    Output
      commit .env / keys / node_modules / venv      rebase or reset shared commits      git push --force to main
      leaked secret → ROTATE FIRST, then purge history

    Investigate

    Output
      git diff --staged · git show <hash> · git blame file · git log -p file
      git bisect start / bad / good <tag> / ... / reset       (git bisect run ./test.sh)

    Try This Yourself#

    1. Recreate the conflict. In ~/git-practice, follow Chapters 2, 4 and 5 exactly: commit quiz.py, branch to bonus, change the return line differently on each branch, merge, resolve, and check your git log --oneline --graph --all matches the one in Chapter 5 (your hashes will differ — why? Hint: Ch 3 — your name, email and time are part of the commit).

    2. Break it and recover. Run git reset --hard HEAD~2. Check git log — commits gone. Now use git reflog to find them and restore the branch. Then try git revert on one commit and look at the new commit it creates with git show.

    3. Bisect for real. Write a loop that makes 20 commits, each appending a number to nums.txt, and on commit 13 also create a file bug.txt. Then bisect with the test "is bug.txt missing?" — git bisect run sh -c '[ ! -f bug.txt ]' — and confirm Git names commit 13.