Web Development — Level 4: Professional Practice — Git, APIs, Testing & Deployment
Free preview

Git essentials

1 / 3

Why version control

  • Full history of every change
  • Undo mistakes safely
  • Work in parallel
2 / 3

The three areas

  • Working directory
  • Staging area (git add)
  • Repository (git commit)
3 / 3

Daily commands

  • git status, git add, git commit -m
  • git log --oneline
  • git diff

Lecture notes

Git records snapshots of your project. You can see who changed what and why, return to any earlier version and work on several features at the same time.

git init                       # start a repository
git config --global user.name "Awa Ndzie"
git status                     # what changed?
git add index.php              # stage a file (git add . for all)
git commit -m "Add course list page"
git log --oneline              # history
git diff                       # unstaged changes

Three areas

  1. Working directory — your files as you edit them.
  2. Staging area — the changes selected for the next commit (git add).
  3. Repository — the saved history (git commit).

Good commits

  • Small and focused: one logical change per commit.
  • A message in the imperative that explains why: "Fix rounding of VAT on invoices".
  • Never commit secrets: list .env, vendor/, node_modules/ in .gitignore.

Undoing

git restore file.php          # discard local changes to a file
git restore --staged file.php # unstage
git revert a1b2c3d            # new commit that undoes an old one (safe on shared branches)
Want to go further?
22 h · Enroll to access every lesson and earn the certificate.
Get Started Free