Skip to main content

Module 1 — Git, GitHub & GitLab Best Practices

Audience: Anyone using Git day to day — developers, writers, infrastructure and platform engineers. If you’ve used Git but not internalized why the model works, this module is for you.

Outcomes: Understand how Git stores history (the inside-out mental model); use the daily workflow (clone → branch → commit → push → PR/MR → merge) without looking up commands; reason about git log, diff, revert; operate comfortably in both GitHub and GitLab with branch protection, CODEOWNERS, and SSO/SAML; and earn the GitHub Foundations certification.


Checklist — work through in order

  • Stage 0 (do first): watch Git For Ages 4 And Up and draw the object model
  • Stage 1: Microsoft Learn — GitHub Fundamentals path + GitHub Skills (in-browser); GitLab users add GitLab for Beginners
  • Stage 2: finish learngitbranching.js.org “Introduction Sequence” + “Ramping Up”; read Pro Git Ch.1–3
  • Work the Mechanics checklist (clone/branch/commit/push/PR, diff, log, revert vs reset, CODEOWNERS, branch protection)
  • Complete enterprise hosting onboarding (SSO-authorized PAT, 2FA)
  • Certify: book GitHub Foundations (GitHub/PSI · $99 · 75 questions · 120 min · 700/1000 · no prerequisites). Study aids: Microsoft Learn GitHub Fundamentals, Pro Git, LadyKerr github-certification-guide
  • Pass the scenario-based Verification at the bottom

Mental model first — not just “how to Git”

Most Git tutorials start with commands. This module starts with the model, because commands make no sense without it. Git stores snapshots, not diffs; commits are immutable, content-addressed objects; branches are labels, not containers. Every confusing moment (detached HEAD, merge vs rebase, rejected pushes) is a model mismatch.

Do Stage 0 before anything else.

Git vs Git hosting platforms

  • Git = decentralized version control (created by Linus Torvalds, 2005). Every developer has the full history. Identical everywhere it’s installed.
  • GitHub / GitLab = hosting services on top of Git: web UI, PRs/MRs, issues, CI/CD, wikis. The collaborative layer differs; Git itself does not care which host you use.
  • Core workflow is identical on both: clone → checkout -b feature → add → commit → push -u origin feature → open PR (GitHub) / MR (GitLab).
GitHubGitLabMeaning
Pull Request (PR)Merge Request (MR)Proposed, reviewed change
GitHub ActionsGitLab CICI/CD (GitLab built-in, GitHub opt-in)
OrganizationsGroupsTeam management
gh CLIglab CLITerminal tooling

Git as the tool for change management

Git doesn’t create governance — the workflows on top do. This reframe is the cultural core of everything later (especially GitOps).

Traditional processGit / hosting-platform equivalent
Change ticketPR / MR — the diff is the change; description is the body
Peer review / approvalPR/MR review — named, required approvers via branch protection
Approval recordMerge commit — named, timestamped, traceable
“Who changed this?”git log, git blame, PR history
Emergency / break-glassEmergency PR with post-hoc review; audit trail preserved
Rollbackgit revert — both change and rollback preserved in history

Git makes governance faster, more traceable, and automatable at the enforcement layer.


Stage 0 — Mental model (free, ~2h)

Git For Ages 4 And Up — Michael Schwern (~1h 40m). Teaches objects → commits → labels → staging → remotes with physical props. After this, detached HEAD, rebase, and reset become logical consequences of the model.

Verification: On paper/whiteboard, draw the relationship between a blob, a tree, a commit object, a branch label, HEAD, and a remote ref. Explain what git commit physically does to those objects.


Stage 1 — Hands-on basics (free, 2–4h)

ResourceWhat it coversLink
Microsoft Learn — GitHub FundamentalsStructured, exam-aligned path: Git basics, GitHub flow, collaboration, PRs, issues, project boardsGitHub Fundamentals (Microsoft Learn)
GitHub Skills (in-browser)Introduction to Git; Introduction to GitHub — automated feedback via Actionsskills.github.com
GitLab for Beginners (in-browser)Same fundamentals in the GitLab UIabout.gitlab.com/learn/gitlab-for-beginners
Microsoft Learn — Introduction to GitModules: Intro to Git (~1h26m), Collaborate with Git (44m), Introduction to GitHublearn.microsoft.com/…/intro-to-git

Verification: Clone a repo, create a branch, edit one line, commit, push, open a PR/MR. Write the description as a change ticket: what changed, why, risk, how to verify.


Stage 2 — Internals & interactive practice (free)

ResourceCoversNotes
learngitbranching.js.orgBranching, merging, rebasing, cherry-pick — visuallyStart with “Introduction Sequence”
Pro Git book (free)Everything; Ch.1–3 fundamentals, Ch.10 internalsDeeper chapters for submodules, rerere, merge strategies

Verification: Complete “Introduction Sequence” + “Ramping Up” of learngitbranching. Explain, without notes, git rebase main vs git merge main on a feature branch.


Mechanics checklist (Day-to-day GitOps work)

TopicWhy it matters
Install Git; set user.name / user.emailEvery commit attributed; matches policy/audit
Clone, remote, fetch vs pullGitOps tooling reads from remotes; needs reproducible local copy
Branch / commit / pushFeature branch → PR → merge to main/env branch
PR/MR lifecycleWhere review/approval gate automation
Diff (git diff, IDE)Constantly compare YAML to cluster behavior
git log / git log --oneline --graph“What changed and when?”
git stashShelve WIP when switching branches
git revert vs git resetrevert safe on shared branches; reset rewrites history (local only)
Org basics: permissions, CODEOWNERS, branch protectionYou may not push to main — that is correct and intentional
Optional: gh / glab CLIOpen PRs/MRs, check CI from terminal

Enterprise hosting notes

  • Complete IT device/token onboarding before pushing — PATs often need one-time SSO authorization.
  • Prefer fine-grained PATs (or deploy keys / service-account tokens for CI) over classic repo-scoped tokens.

Certification

CertificationAligns withNotes
GitHub FoundationsStage 0–2 + enterprise notesValidates Git + GitHub fundamentals; pair with the Microsoft GitHub Fundamentals learn path as study material. Exam booked via

Verification (scenario-based)

  1. Clone → branch → edit → push → PR: as above, with ticket-style description.
  2. Explain the model: without notes — git commit (local) vs git push (publish); git pull (laptop) vs merging a PR/MR (review gates, approval record, audit).
  3. Read history: from git log, answer who changed deployment.yaml two weeks ago, what, and was it reviewed?
  4. Recover: make a bad commit on a feature branch; git revert it; explain why not git reset on a shared branch.