Opscraft
Foundations: Linux, scripting, Git & networking

Git

New8 lessons · 29 min · 3 tests ·

Git is the foundation of every DevOps workflow: CI pipelines trigger on it, GitOps treats it as the source of truth, and code review, releases and audit trails all live in it. Senior interviews go beyond add/commit/push: they ask how Git stores data, merge vs rebase and when each is dangerous, how to recover from mistakes (a force-push, a leaked secret, a bad merge on main), which branching strategy suits continuous delivery, and how to run repositories at scale in CI.

Stage 1 · Foundations

Know these first

After this topic you can

  • Branch, commit, merge and rebase with confidence
  • Recover from mistakes such as a bad force-push
  • Set up branch protection and a clean pull-request workflow

Lessons

  1. 1How Git stores data 4 min read
    • Snapshots, not diffs
    • The object database
    • References: branches, HEAD and tags
    • The three areas
  2. 2Everyday workflow and investigating history 3 min read
    • Core commands
    • git bisect — find the commit that broke something
    • git reflog — your safety net
  3. 3Merging and rebasing 4 min read
    • Merge
    • Rebase
    • Interactive rebase: clean up before review
    • Merge strategies on pull requests
    • Resolving conflicts
  4. 4Undoing things safely 5 min read
    • Pick the right tool
    • Force pushes
    • A secret was committed
  5. 5Remotes and team collaboration 3 min read
    • Remotes, fetch, pull and push
    • Pull requests and code review
    • Forks vs branches
  6. 6Branching strategies 4 min read
    • Trunk-based development
    • GitFlow
    • GitHub flow
    • Release branches
    • Environment branches: an anti-pattern in GitOps
    • Versioning and releases
  7. 7Repositories at scale and in CI 3 min read
    • Monorepo vs polyrepo
    • Making Git fast in CI
    • Large files, submodules and hooks
    • Git hosting for DevOps
  8. 8Interview questions and model answers 3 min read
    • "Merge vs rebase — which do you use?"
    • "How do you undo a bad commit that's already pushed to main?"
    • "What's the difference between reset --soft, --mixed and --hard?"
    • "Someone committed an AWS key to the repo. What do you do?"
    • "Trunk-based development or GitFlow?"
    • "How would you find which commit introduced a bug?"
    • "Your CI uses shallow clones and versioning from tags broke. Why?"
    • "How do you structure a GitOps config repo for multiple environments?"